/* */ #include "DHTUnknownMessage.h" #include #include #include "DHTNode.h" #include "util.h" #include "a2functional.h" namespace aria2 { const std::string DHTUnknownMessage::E("e"); const std::string DHTUnknownMessage::UNKNOWN("unknown"); DHTUnknownMessage::DHTUnknownMessage(const SharedHandle& localNode, const unsigned char* data, size_t length, const std::string& ipaddr, uint16_t port): DHTMessage(localNode, SharedHandle()), length_(length), ipaddr_(ipaddr), port_(port) { if(length_ == 0) { data_ = 0; } else { data_ = new unsigned char[length]; memcpy(data_, data, length); } } DHTUnknownMessage::~DHTUnknownMessage() { delete [] data_; } void DHTUnknownMessage::doReceivedAction() {} bool DHTUnknownMessage::send() { return true; } bool DHTUnknownMessage::isReply() const { return false; } const std::string& DHTUnknownMessage::getMessageType() const { return UNKNOWN; } std::string DHTUnknownMessage::toString() const { size_t sampleLength = 8; if(length_ < sampleLength) { sampleLength = length_; } return fmt("dht unknown Remote:%s(%u) length=%lu, first 8 bytes(hex)=%s", ipaddr_.c_str(), port_, static_cast(length_), util::toHex(data_, sampleLength).c_str()); } } // namespace aria2