/* */ #ifndef D_DHT_TOKEN_TRACKER_H #define D_DHT_TOKEN_TRACKER_H #include "common.h" #include namespace aria2 { class DHTTokenTracker { private: static const size_t SECRET_SIZE = 4; unsigned char secret_[2][SECRET_SIZE]; std::string generateToken(const unsigned char* infoHash, const std::string& ipaddr, uint16_t port, const unsigned char* secret) const; public: DHTTokenTracker(); DHTTokenTracker(const unsigned char* initialSecret); ~DHTTokenTracker(); // TODO handle exception thrown by this function. std::string generateToken(const unsigned char* infoHash, const std::string& ipaddr, uint16_t port) const; bool validateToken(const std::string& token, const unsigned char* infoHash, const std::string& ipaddr, uint16_t port) const; void updateTokenSecret(); }; } // namespace aria2 #endif // D_DHT_TOKEN_TRACKER_H