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

Cette révision appartient à :
ps 2014-06-28 16:46:04 +00:00
Parent 0b0c956dd5
révision 53acbb57c8
5 fichiers modifiés avec 36 ajouts et 3 suppressions

Voir le fichier

@ -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);
@ -300,8 +304,8 @@ void Proxy::run(string &peer_address)
//or to not advertise it as the last capability.
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())

Voir le fichier

@ -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
*

Voir le fichier

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

Voir le fichier

@ -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;

Voir le fichier

@ -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