#ifndef D_MOCK_DHT_MESSAGE_FACTORY_H #define D_MOCK_DHT_MESSAGE_FACTORY_H #include "DHTMessageFactory.h" #include "DHTNode.h" #include "MockDHTMessage.h" #include "DHTPingMessage.h" #include "DHTPingReplyMessage.h" #include "DHTFindNodeMessage.h" #include "DHTFindNodeReplyMessage.h" #include "DHTGetPeersMessage.h" #include "DHTGetPeersReplyMessage.h" #include "DHTAnnouncePeerMessage.h" #include "DHTAnnouncePeerReplyMessage.h" #include "DHTUnknownMessage.h" namespace aria2 { class MockDHTMessageFactory:public DHTMessageFactory { protected: std::shared_ptr localNode_; public: MockDHTMessageFactory() {} virtual std::unique_ptr createQueryMessage(const Dict* dict, const std::string& ipaddr, uint16_t port) CXX11_OVERRIDE { return nullptr; } virtual std::unique_ptr createResponseMessage(const std::string& messageType, const Dict* dict, const std::string& ipaddr, uint16_t port) CXX11_OVERRIDE { auto remoteNode = std::make_shared(); // TODO At this point, removeNode's ID is random. remoteNode->setIPAddress(ipaddr); remoteNode->setPort(port); return make_unique (localNode_, remoteNode, downcast(dict->get("t"))->s()); } virtual std::unique_ptr createPingMessage(const std::shared_ptr& remoteNode, const std::string& transactionID = "") CXX11_OVERRIDE { return nullptr; } virtual std::unique_ptr createPingReplyMessage(const std::shared_ptr& remoteNode, const unsigned char* remoteNodeID, const std::string& transactionID) CXX11_OVERRIDE { return nullptr; } virtual std::unique_ptr createFindNodeMessage(const std::shared_ptr& remoteNode, const unsigned char* targetNodeID, const std::string& transactionID = "") CXX11_OVERRIDE { return nullptr; } virtual std::unique_ptr createFindNodeReplyMessage (const std::shared_ptr& remoteNode, std::vector> closestKNodes, const std::string& transactionID) CXX11_OVERRIDE { return nullptr; } virtual std::unique_ptr createGetPeersMessage(const std::shared_ptr& remoteNode, const unsigned char* infoHash, const std::string& transactionID) CXX11_OVERRIDE { return nullptr; } virtual std::unique_ptr createGetPeersReplyMessage (const std::shared_ptr& remoteNode, std::vector> closestKNodes, std::vector> peers, const std::string& token, const std::string& transactionID) CXX11_OVERRIDE { return nullptr; } virtual std::unique_ptr createAnnouncePeerMessage(const std::shared_ptr& remoteNode, const unsigned char* infoHash, uint16_t tcpPort, const std::string& token, const std::string& transactionID = "") CXX11_OVERRIDE { return nullptr; } virtual std::unique_ptr createAnnouncePeerReplyMessage(const std::shared_ptr& remoteNode, const std::string& transactionID) CXX11_OVERRIDE { return nullptr; } virtual std::unique_ptr createUnknownMessage(const unsigned char* data, size_t length, const std::string& ipaddr, uint16_t port) CXX11_OVERRIDE { return nullptr; } void setLocalNode(const std::shared_ptr& node) { localNode_ = node; } }; } // namespace aria2 #endif // D_MOCK_DHT_MESSAGE_FACTORY_H