📄 waripshitlisted.cpp
字号:
#include "StdAfx.h"#include "WarIpShitlisted.h" // class implemented#ifndef WAR_LOG_H# include "WarLog.h"#endif/////////////////////////////// PUBLIC /////////////////////////////////////////============================= LIFECYCLE ====================================WarIpShitlisted::WarIpShitlisted(ReasonE becauseReason, const struct in_addr& ipAddr, int expireSeconds) throw(WarException) : mReason(becauseReason){ static const int default_timeout[REASON_INVALID] = { (60 * 15), // REASON_HAMMERING (60 * 60 * 24), // REASON_CRACKING (60 * 60 * 12), // REASON_MANUALLY_SET (60 * 60 * 6) // REASON_FLOOD }; if ((0 > becauseReason) || (REASON_INVALID <= becauseReason)) WarThrow(WarError(WAR_ERR_OUT_OF_RANGE), NULL); if (0 == expireSeconds) expireSeconds = default_timeout[becauseReason]; mAddr.s_addr = ipAddr.s_addr; mExpieres.Reset(expireSeconds * 1000); }// WarIpShitlisted//============================= OPERATORS ====================================//============================= OPERATIONS ===================================//============================= ACCESS ===================================//============================= INQUIRY ===================================void WarIpShitlisted::LogWhy() const{ WarLog security_log(WARLOG_SECURITY, "WarIpShitlisted::WarIpShitlisted()"); security_log << "The IP address " << mAddr << " was shitlisted until " << GetExpireTime().FormatLT() << " because " << Explain() << '.' << war_endl;}std::string WarIpShitlisted::Explain() const{ war_ccstr_t p = "Unknown reason"; switch(mReason) { case REASON_HAMMERING: p = "hammering"; break; case REASON_CRACKING: p = "cracking"; break; case REASON_MANUALLY_SET: p = "an operator decided so"; break; case REASON_FLOOD: p = "exessive flood"; break; } return p;}/////////////////////////////// PROTECTED ////////////////////////////////////////////////////////////////// PRIVATE ///////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -