add the add_status_header_if_dns_listed option

This commit is contained in:
ps 2011-06-28 21:46:35 +00:00
parent a9ce0d5e33
commit cc73e91bf8
2 changed files with 15 additions and 1 deletions

View file

@ -107,6 +107,12 @@ list,dns_whitelist_domains,""
* as listed, just define dns_whitelist_percentage as 50 (50%). * as listed, just define dns_whitelist_percentage as 50 (50%).
int,dns_whitelist_percentage,100 int,dns_whitelist_percentage,100
* if this is enabled, email will get tagged with a header "X-Hermes-Status: {white,black}listed"
* that way, your bayesian filter can learn from this automatically
* NOTE: if this is enabled, it will accept blacklisted emails and it will be up to you to filter
* them out, for example through procmail
bool,add_status_header_if_dns_listed,false
* time to delay the initial SMTP banner * time to delay the initial SMTP banner
int,banner_delay_time,5 int,banner_delay_time,5

View file

@ -52,11 +52,13 @@ void Proxy::run(string &peer_address)
bool authenticated=false; //we start with a non-authenticated connection bool authenticated=false; //we start with a non-authenticated connection
bool esmtp=false; bool esmtp=false;
string strtemp; string strtemp;
string hermes_status="unknown";
//check whitelist //check whitelist
if(!cfg.getDnsWhitelistDomains().empty()&&Utils::listed_on_dns_lists(cfg.getDnsWhitelistDomains(),cfg.getDnsWhitelistPercentage(),peer_address)) if(!cfg.getDnsWhitelistDomains().empty()&&Utils::listed_on_dns_lists(cfg.getDnsWhitelistDomains(),cfg.getDnsWhitelistPercentage(),peer_address))
{ {
authenticated=true; authenticated=true;
hermes_status="whitelisted";
if(true==cfg.getWhitelistedDisablesEverything()) if(true==cfg.getWhitelistedDisablesEverything())
throttled=false; throttled=false;
} }
@ -159,6 +161,10 @@ void Proxy::run(string &peer_address)
//check rbl //check rbl
else if(!cfg.getDnsBlacklistDomains().empty()&&!authenticated&&Utils::listed_on_dns_lists(cfg.getDnsBlacklistDomains(),cfg.getDnsBlacklistPercentage(),peer_address)) else if(!cfg.getDnsBlacklistDomains().empty()&&!authenticated&&Utils::listed_on_dns_lists(cfg.getDnsBlacklistDomains(),cfg.getDnsBlacklistPercentage(),peer_address))
{ {
hermes_status="blacklisted";
if(cfg.getAddStatusHeaderIfDnsListed())
code="250";
else
code=cfg.getReturnTempErrorOnReject()?"421":"550"; code=cfg.getReturnTempErrorOnReject()?"421":"550";
mechanism="dnsbl"; mechanism="dnsbl";
message=code+" You are listed on some DNS blacklists. Get delisted before trying to send us email."; message=code+" You are listed on some DNS blacklists. Get delisted before trying to send us email.";
@ -246,6 +252,8 @@ void Proxy::run(string &peer_address)
inside.writeLine(" by "+Utils::gethostname()+" with "+(esmtp?"ESTMP":"SMTP")+" via TCP; "+Utils::rfc2821_date()); inside.writeLine(" by "+Utils::gethostname()+" with "+(esmtp?"ESTMP":"SMTP")+" via TCP; "+Utils::rfc2821_date());
inside.writeLine("X-Anti-Spam-Proxy: Proxied by Hermes [www.hermes-project.com]"); inside.writeLine("X-Anti-Spam-Proxy: Proxied by Hermes [www.hermes-project.com]");
} }
if(cfg.getAddStatusHeaderIfDnsListed())
inside.writeLine("X-Hermes-Status: "+hermes_status);
do do
{ {
bytes_read=outside.readBytes(buffer,sizeof(buffer)-1); bytes_read=outside.readBytes(buffer,sizeof(buffer)-1);