Hello,

I have been asked to build a mechanism called anti-hammering for FTP server. It should work like this:

If it is enabled,

USER a
PASS b
(either or both one of these are not correct)
Wait 2 secs and then re-ask for USER

However since ICS is async, I cannot use the Sleep(2000) call not to block other users! My code is like this:

void __fastcall TFTPServer::CommandPASS(
    TFtpCtrlSocket *Client,
    TFtpString &Keyword,
    TFtpString &Params,
    TFtpString &Answer)
{
       if(Client->FtpState != ftpcWaitingPassword)
               Answer = msgNoUser;
       else
       {
               ....

if(Authenticated)
{
Client->FtpState = ftpcReady;
Client->Directory = "\\";
// Answer = String(Answer) + Format(msgLogged, ARRAYOFCONST((Client->UserName)));
}
else
{
if(stopHammering)
{
dynamic_cast<ftpServerClientClass*>(Client)->lastPASS = Now();
dynamic_cast<ftpServerClientClass*>(Client)->antiHammeringTime = true;
!!!!!! HERE I HAVE TO STOP THE COMPONENT TO RESPOND TO THE CLIENT AND IN THE TIMER I HAVE I WANT TO SET THE STATE TO ftpcWaitingUserCode and then PROCEED WITHOUT AFFECTING OTHER USERS. !!!!!!
}
else
Client->FtpState = ftpcWaitingUserCode;
// Answer = msgLoginFailed;
}
}
}
//---------------------------------------------------------------------------


Hope you can help.

Best Regards,

SubZero


-- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be

Reply via email to