From ae957baa98d4f97ea2437596db5073f9c33d22ae Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 20 Jun 2010 12:28:11 +0000 Subject: [PATCH] 2010-06-20 Tatsuhiro Tsujikawa When wrong type DHT reply message is received for a transaction ID, assume the message timed out. * src/DHTNodeLookupTaskCallback.cc * src/DHTNodeLookupTaskCallback.h * src/DHTPeerLookupTaskCallback.cc * src/DHTPeerLookupTaskCallback.h * src/DHTPingReplyMessageCallback.h --- ChangeLog | 10 ++++++++++ src/DHTNodeLookupTaskCallback.cc | 24 ++++++++++++++++++++++++ src/DHTNodeLookupTaskCallback.h | 6 +++--- src/DHTPeerLookupTaskCallback.cc | 20 ++++++++++++++++++++ src/DHTPeerLookupTaskCallback.h | 6 +++--- src/DHTPingReplyMessageCallback.h | 19 ++++++++++++++++--- 6 files changed, 76 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 006b7e72..0cda9819 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2010-06-20 Tatsuhiro Tsujikawa + + When wrong type DHT reply message is received for a transaction + ID, assume the message timed out. + * src/DHTNodeLookupTaskCallback.cc + * src/DHTNodeLookupTaskCallback.h + * src/DHTPeerLookupTaskCallback.cc + * src/DHTPeerLookupTaskCallback.h + * src/DHTPingReplyMessageCallback.h + 2010-06-20 Tatsuhiro Tsujikawa Removed PeerListProcessor. Its functionality is now moved to diff --git a/src/DHTNodeLookupTaskCallback.cc b/src/DHTNodeLookupTaskCallback.cc index 0b0fd197..0c2c3009 100644 --- a/src/DHTNodeLookupTaskCallback.cc +++ b/src/DHTNodeLookupTaskCallback.cc @@ -34,21 +34,45 @@ /* copyright --> */ #include "DHTNodeLookupTaskCallback.h" #include "DHTNodeLookupTask.h" +#include "DHTAnnouncePeerReplyMessage.h" +#include "DHTGetPeersReplyMessage.h" +#include "DHTPingReplyMessage.h" +#include "Peer.h" namespace aria2 { DHTNodeLookupTaskCallback::DHTNodeLookupTaskCallback(DHTNodeLookupTask* task): _task(task) {} +void DHTNodeLookupTaskCallback::visit +(const DHTAnnouncePeerReplyMessage* message) +{ + // When wrong message type is received, forced to timeout + onTimeout(message->getRemoteNode()); +} + void DHTNodeLookupTaskCallback::visit(const DHTFindNodeReplyMessage* message) { _task->onReceived(message); } +void DHTNodeLookupTaskCallback::visit(const DHTGetPeersReplyMessage* message) +{ + // When wrong message type is received, forced to timeout + onTimeout(message->getRemoteNode()); +} + +void DHTNodeLookupTaskCallback::visit(const DHTPingReplyMessage* message) +{ + // When wrong message type is received, forced to timeout + onTimeout(message->getRemoteNode()); +} + void DHTNodeLookupTaskCallback::onTimeout (const SharedHandle& remoteNode) { _task->onTimeout(remoteNode); } + } // namespace aria2 diff --git a/src/DHTNodeLookupTaskCallback.h b/src/DHTNodeLookupTaskCallback.h index 02bdd757..64ecc84e 100644 --- a/src/DHTNodeLookupTaskCallback.h +++ b/src/DHTNodeLookupTaskCallback.h @@ -47,13 +47,13 @@ private: public: DHTNodeLookupTaskCallback(DHTNodeLookupTask* task); - virtual void visit(const DHTAnnouncePeerReplyMessage* message) {} + virtual void visit(const DHTAnnouncePeerReplyMessage* message); virtual void visit(const DHTFindNodeReplyMessage* message); - virtual void visit(const DHTGetPeersReplyMessage* message) {} + virtual void visit(const DHTGetPeersReplyMessage* message); - virtual void visit(const DHTPingReplyMessage* message) {} + virtual void visit(const DHTPingReplyMessage* message); virtual void onTimeout(const SharedHandle& remoteNode); }; diff --git a/src/DHTPeerLookupTaskCallback.cc b/src/DHTPeerLookupTaskCallback.cc index 5343dc70..49a9827a 100644 --- a/src/DHTPeerLookupTaskCallback.cc +++ b/src/DHTPeerLookupTaskCallback.cc @@ -34,17 +34,37 @@ /* copyright --> */ #include "DHTPeerLookupTaskCallback.h" #include "DHTPeerLookupTask.h" +#include "DHTAnnouncePeerReplyMessage.h" +#include "DHTFindNodeReplyMessage.h" +#include "DHTPingReplyMessage.h" +#include "Peer.h" namespace aria2 { DHTPeerLookupTaskCallback::DHTPeerLookupTaskCallback(DHTPeerLookupTask* task): _task(task) {} +void DHTPeerLookupTaskCallback::visit +(const DHTAnnouncePeerReplyMessage* message) +{ + onTimeout(message->getRemoteNode()); +} + +void DHTPeerLookupTaskCallback::visit(const DHTFindNodeReplyMessage* message) +{ + onTimeout(message->getRemoteNode()); +} + void DHTPeerLookupTaskCallback::visit(const DHTGetPeersReplyMessage* message) { _task->onReceived(message); } +void DHTPeerLookupTaskCallback::visit(const DHTPingReplyMessage* message) +{ + onTimeout(message->getRemoteNode()); +} + void DHTPeerLookupTaskCallback::onTimeout (const SharedHandle& remoteNode) { diff --git a/src/DHTPeerLookupTaskCallback.h b/src/DHTPeerLookupTaskCallback.h index ef865ee7..35b25774 100644 --- a/src/DHTPeerLookupTaskCallback.h +++ b/src/DHTPeerLookupTaskCallback.h @@ -47,13 +47,13 @@ private: public: DHTPeerLookupTaskCallback(DHTPeerLookupTask* task); - virtual void visit(const DHTAnnouncePeerReplyMessage* message) {} + virtual void visit(const DHTAnnouncePeerReplyMessage* message); - virtual void visit(const DHTFindNodeReplyMessage* message) {} + virtual void visit(const DHTFindNodeReplyMessage* message); virtual void visit(const DHTGetPeersReplyMessage* message); - virtual void visit(const DHTPingReplyMessage* message) {} + virtual void visit(const DHTPingReplyMessage* message); virtual void onTimeout(const SharedHandle& remoteNode); }; diff --git a/src/DHTPingReplyMessageCallback.h b/src/DHTPingReplyMessageCallback.h index e8bad843..eb6e16c4 100644 --- a/src/DHTPingReplyMessageCallback.h +++ b/src/DHTPingReplyMessageCallback.h @@ -36,6 +36,10 @@ #define _D_DHT_PING_REPLY_MESSAGE_CALLBACK_H_ #include "DHTMessageCallback.h" +#include "DHTAnnouncePeerReplyMessage.h" +#include "DHTFindNodeReplyMessage.h" +#include "DHTGetPeersReplyMessage.h" +#include "Peer.h" namespace aria2 { @@ -46,11 +50,20 @@ private: public: DHTPingReplyMessageCallback(Task* task):_task(task) {} - virtual void visit(const DHTAnnouncePeerReplyMessage* message) {} + virtual void visit(const DHTAnnouncePeerReplyMessage* message) + { + onTimeout(message->getRemoteNode()); + } - virtual void visit(const DHTFindNodeReplyMessage* message) {} + virtual void visit(const DHTFindNodeReplyMessage* message) + { + onTimeout(message->getRemoteNode()); + } - virtual void visit(const DHTGetPeersReplyMessage* message) {} + virtual void visit(const DHTGetPeersReplyMessage* message) + { + onTimeout(message->getRemoteNode()); + } virtual void visit(const DHTPingReplyMessage* message) {