/* */ #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_