Skip to content
This repository was archived by the owner on Apr 27, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion common/src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ maildrop {

sender {
greylist {
enabled = true
response = "You have been temporarily greylisted. Please try back later."
time = 5m
}
Expand Down Expand Up @@ -44,4 +45,4 @@ maildrop {
// db = 2
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import scala.concurrent.ExecutionContext.Implicits.global

object GreylistFilter extends LazyLogging {

val enabled = MailDropConfig("maildrop.sender.greylist.enabled").getOrElse("true")
val reason = MailDropConfig("maildrop.sender.greylist.response").getOrElse("Greylisted")
val ttl = MailDropConfig.getSeconds("maildrop.sender.greylist.time").getOrElse(300L).toInt
val system = ActorSystem()
Expand All @@ -37,19 +38,25 @@ object GreylistFilter extends LazyLogging {
// }

def apply(host: Map[String, String], inet: InetAddress, helo: String): Future[Product] = Future {
logger.debug("checking greylist entry for " + inet.getHostAddress + "/" + helo)
host.get("greylist") match {
case Some(str) => Continue()
case None =>
system.scheduler.scheduleOnce(new FiniteDuration(ttl, duration.SECONDS))({ GreylistFilter.add(inet, helo) })
Greylist(reason)
}
if (enabled == "true") {
logger.debug("checking greylist entry for " + inet.getHostAddress + "/" + helo)
host.get("greylist") match {
case Some(str) => Continue()
case None =>
system.scheduler.scheduleOnce(new FiniteDuration(ttl, duration.SECONDS))({ GreylistFilter.add(inet, helo) })
Greylist(reason)
}
} else {
Continue()
}
}

def add(inet: InetAddress, helo: String) {
logger.debug("adding greylist entry for " + inet.getHostAddress + "/" + helo)
Redis.client.hset(HostEntry.key(inet, helo), "greylist", "y")
HostEntry.touch(inet, helo)
if (enabled == "true") {
logger.debug("adding greylist entry for " + inet.getHostAddress + "/" + helo)
Redis.client.hset(HostEntry.key(inet, helo), "greylist", "y")
HostEntry.touch(inet, helo)
}
}

}