ADD: some more information to the headers injected into the emails by hermes
This commit is contained in:
parent
0b0c956dd5
commit
53acbb57c8
|
@ -260,10 +260,14 @@ void Proxy::run(string &peer_address)
|
||||||
|
|
||||||
outside.writeLine(strtemp);
|
outside.writeLine(strtemp);
|
||||||
strtemp="";
|
strtemp="";
|
||||||
|
string ssltls="";
|
||||||
|
if (outside.is_ssl_enabled())
|
||||||
|
ssltls=" (SSL/TLS)";
|
||||||
|
|
||||||
if(cfg.getAddHeaders())
|
if(cfg.getAddHeaders())
|
||||||
{
|
{
|
||||||
inside.writeLine("Received: from "+ehlostr+" ("+peer_address+")");
|
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]");
|
inside.writeLine("X-Anti-Spam-Proxy: Proxied by Hermes [www.hermes-project.com]");
|
||||||
if(cfg.getAddStatusHeader())
|
if(cfg.getAddStatusHeader())
|
||||||
inside.writeLine("X-Hermes-Status: "+hermes_status);
|
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.
|
//or to not advertise it as the last capability.
|
||||||
if("250 pipelining"==Utils::strtolower(strtemp)||"250 chunking"==Utils::strtolower(strtemp))
|
if("250 pipelining"==Utils::strtolower(strtemp)||"250 chunking"==Utils::strtolower(strtemp))
|
||||||
strtemp="250 x-noextension";
|
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("502"==code) //502 unimplemented -> count them, if bigger than a certain number, terminate connection
|
||||||
{
|
{
|
||||||
if(cfg.getNumberOfUnimplementedCommandsAllowed()!=-1&&++unimplemented_requests>cfg.getNumberOfUnimplementedCommandsAllowed())
|
if(cfg.getNumberOfUnimplementedCommandsAllowed()!=-1&&++unimplemented_requests>cfg.getNumberOfUnimplementedCommandsAllowed())
|
||||||
|
|
|
@ -153,6 +153,15 @@ Socket::~Socket()
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_SSL
|
#ifdef HAVE_SSL
|
||||||
|
|
||||||
|
/**
|
||||||
|
* is ssl enabled on the socket?
|
||||||
|
*/
|
||||||
|
bool Socket::is_ssl_enabled()
|
||||||
|
{
|
||||||
|
return ssl_enabled;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* prepare ssl on the socket
|
* prepare ssl on the socket
|
||||||
*
|
*
|
||||||
|
|
|
@ -75,6 +75,7 @@ class Socket
|
||||||
Socket();
|
Socket();
|
||||||
~Socket();
|
~Socket();
|
||||||
#ifdef HAVE_SSL
|
#ifdef HAVE_SSL
|
||||||
|
bool is_ssl_enabled();
|
||||||
void prepareSSL(bool);
|
void prepareSSL(bool);
|
||||||
void startSSL(bool);
|
void startSSL(bool);
|
||||||
#endif //HAVE_SSL
|
#endif //HAVE_SSL
|
||||||
|
|
|
@ -622,6 +622,24 @@ string Utils::gethostname()
|
||||||
return string(buf);
|
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)
|
void Utils::write_pid(string file,pid_t pid)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
|
@ -82,6 +82,7 @@ class Utils
|
||||||
static string rfc2821_date(time_t *timestamp=NULL);
|
static string rfc2821_date(time_t *timestamp=NULL);
|
||||||
static string gethostname();
|
static string gethostname();
|
||||||
static void write_pid(string,pid_t);
|
static void write_pid(string,pid_t);
|
||||||
|
static string gethostname(int s);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //UTILS_H
|
#endif //UTILS_H
|
||||||
|
|
Loading…
Reference in a new issue