waripshitlisted.h

来自「ftpserver very good sample」· C头文件 代码 · 共 171 行

H
171
字号
/** */#ifndef WAR_IP_SHITLIST_H#define WAR_IP_SHITLIST_H/* SYSTEM INCLUDES */#ifdef HAVE_NETINET_IN_H#   ifndef WAR_NETINET_IN_H_INCLUDED#       define WAR_NETINET_IN_H_INCLUDED#       include <netinet/in.h>#   endif#endif/* PROJECT INCLUDES */#ifndef WAR_TIME_H#   include "WarTime.h"#endif/* LOCAL INCLUDES *//* FORWARD REFERENCES */#ifdef __cplusplusextern "C" {#endif/****************** BEGIN OLD STYLE C spesific ********//****************** END OLD STYLE C spesific **********/#ifdef __cplusplus }#endif/****************** BEGIN C++ spesific ****************/#ifdef __cplusplusclass WarIpShitlisted {public:    enum ReasonE    {        REASON_HAMMERING,        REASON_CRACKING,        REASON_MANUALLY_SET,        REASON_FLOOD,        REASON_INVALID    };    // LIFECYCLE        /**    * Default constructor.    */    WarIpShitlisted(ReasonE becauseReason,        const struct in_addr& ipAddr,         int expireSeconds = 0)        throw(WarException);    WarIpShitlisted()    {        mAddr.s_addr = 0;        mReason = REASON_INVALID;    }        /**    * Copy constructor.    *    * @param from The value to copy to this object.    */    WarIpShitlisted(const WarIpShitlisted& from)    {        operator = (from);    }        /**    * Destructor.    */    ~WarIpShitlisted()     {    }        // OPERATORS        /**    * Assignment operator.    *    * @param from THe value to assign to this object.    *    * @return A reference to this object.    */    WarIpShitlisted& operator=(const WarIpShitlisted& from)    {        mAddr = from.mAddr;        mExpieres = from.mExpieres;        mReason = from.mReason;        return *this;    }    bool operator == (const WarIpShitlisted& from) const    {        return mAddr.s_addr == from.mAddr.s_addr;    }    bool operator < (const WarIpShitlisted& from) const    {        return mAddr.s_addr < from.mAddr.s_addr;    }    // OPERATIONS    // CALLBACK    // ACCESS    // INQUIRY    const ReasonE GetReason()     {        return mReason;    }    const struct in_addr& GetIpAddr() const    {        return mAddr;    }    const WarTime& GetExpireTime() const    {        return mExpieres;    }    bool IsTimeOut() const    {        return GetExpireTime().IsTimeOut();    }    const WarTime& GetCreatedTime() const    {        return mCreated;    }    std::string Explain() const;    void LogWhy() const;    protected:private:    struct in_addr mAddr;    WarTime mExpieres;    WarTime mCreated;    ReasonE mReason;};/* INLINE METHODS *//* EXTERNAL REFERENCES */#endif /* __cplusplus *//****************** END C++ spesific ******************/#endif  /* WAR_IP_SHITLIST_H_ */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?