ADD: some more information to the headers injected into the emails by hermes

This commit is contained in:
ps 2014-06-28 16:46:04 +00:00
parent 0b0c956dd5
commit 53acbb57c8
5 changed files with 36 additions and 3 deletions

View file

@ -260,10 +260,14 @@ void Proxy::run(string &peer_address)
outside.writeLine(strtemp);
strtemp="";
string ssltls="";
if (outside.is_ssl_enabled())
ssltls=" (SSL/TLS)";
if(cfg.getAddHeaders())
{
inside.writeLine("Received: from "+ehlostr+" ("+peer_address+")");
inside.writeLine(" by "+Utils::gethostname()+" with "+(esmtp?"ESTMP":"SMTP")+" via TCP; "+Utils::rfc2821_date());
inside.writeLine(" by "+Utils::gethostname(outside.getFD())+" with "+(esmtp?"ESTMP":"SMTP")+ssltls+" via TCP; "+Utils::rfc2821_date());
inside.writeLine("X-Anti-Spam-Proxy: Proxied by Hermes [www.hermes-project.com]");
if(cfg.getAddStatusHeader())
inside.writeLine("X-Hermes-Status: "+hermes_status);
@ -301,7 +305,7 @@ void Proxy::run(string &peer_address)
if("250 pipelining"==Utils::strtolower(strtemp)||"250 chunking"==Utils::strtolower(strtemp))
strtemp="250 x-noextension";
//try to annoy spammers who send us too many senseless commands by delaying their connection a lot
//try to annoy spammers who send us too many senseless commands by delaying their connection a lot
if("502"==code) //502 unimplemented -> count them, if bigger than a certain number, terminate connection
{
if(cfg.getNumberOfUnimplementedCommandsAllowed()!=-1&&++unimplemented_requests>cfg.getNumberOfUnimplementedCommandsAllowed())

View file

@ -153,6 +153,15 @@ Socket::~Socket()
}
#ifdef HAVE_SSL
/**
* is ssl enabled on the socket?
*/
bool Socket::is_ssl_enabled()
{
return ssl_enabled;
}
/**
* prepare ssl on the socket
*

View file

@ -75,6 +75,7 @@ class Socket
Socket();
~Socket();
#ifdef HAVE_SSL
bool is_ssl_enabled();
void prepareSSL(bool);
void startSSL(bool);
#endif //HAVE_SSL

View file

@ -622,6 +622,24 @@ string Utils::gethostname()
return string(buf);
}
string Utils::gethostname(int s)
{
struct sockaddr_in sa;
unsigned int dummy = sizeof sa;
struct hostent *hp;
if (getsockname(s,(struct sockaddr *) &sa,&dummy) == -1)
throw Exception("Error getting ip from socket"+Utils::errnotostrerror(errno),__FILE__,__LINE__);
hp=gethostbyaddr((const void *)&sa.sin_addr,sizeof sa.sin_addr,AF_INET);
if (hp==NULL)
return gethostname();
return string(hp->h_name);
}
void Utils::write_pid(string file,pid_t pid)
{
FILE *f;

View file

@ -82,6 +82,7 @@ class Utils
static string rfc2821_date(time_t *timestamp=NULL);
static string gethostname();
static void write_pid(string,pid_t);
static string gethostname(int s);
};
#endif //UTILS_H