ADD: number_of_unimplemented_commands_allowed and related code

このコミットが含まれているのは:
ps 2012-03-21 22:10:07 +00:00
コミット 33f53a7403
2個のファイルの変更20行の追加0行の削除

ファイルの表示

@ -80,6 +80,11 @@ bool,throttle,true
* don't set this too high (more than 3), as that will drop MANY connections
int,throttling_time,1
* number of unimplemented responses allowed
* this is the total number of "503 Unimplemented" responses allowed from the server
* -1 = unlimited
int,number_of_unimplemented_commands_allowed,-1
* whether we should check if there is data before we send the SMTP banner.
* if there is data the email is almost certainly spam.
bool,allow_data_before_banner,false

ファイルの表示

@ -45,6 +45,7 @@ void Proxy::run(string &peer_address)
string ehlostr="";
string resolvedname="";
unsigned char last_state=SMTP_STATE_WAIT_FOR_HELO;
long unimplemented_requests=0;
try
{
@ -299,6 +300,20 @@ 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
if("502"==code) //502 unimplemented -> count them, if bigger than a certain number, terminate connection
{
if(cfg.getNumberOfUnimplementedCommandsAllowed()!=-1&&++unimplemented_requests>cfg.getNumberOfUnimplementedCommandsAllowed())
{
inside.writeLine("QUIT");
inside.close(); //close the socket now and leave server alone
sleep(60);
outside.writeLine("502 Too many unimplemented commands, closing connection");
return;
}
}
if(strtemp.length())
outside.writeLine(strtemp);
}