summaryrefslogtreecommitdiff
path: root/src/DHTMessageFactoryImpl.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-10-26 12:36:41 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-10-26 12:36:41 +0000
commit8a920ba5e38b8a7c43dc088b1837026e69b078f3 (patch)
treeb36f8ed8a9cc8a39f134cf89bb77fb0fda75bc4e /src/DHTMessageFactoryImpl.cc
parent90c6d5072b70e51ad754c31436abf9479a288769 (diff)
2008-10-26 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Changed signature of DHTMessageFactory::createResponseMessage(). Removed unused validateIDMatch. * src/DHTMessageFactory.h * src/DHTMessageFactoryImpl.cc * src/DHTMessageFactoryImpl.h * src/DHTMessageTracker.cc * test/DHTMessageFactoryImplTest.cc * test/MockDHTMessageFactory.h Dropped DHT message coming from same ID of localhost. * src/DHTMessageReceiver.cc Rejected adding node whose ID is the same as localhost's. * src/DHTRoutingTable.cc * test/BtPortMessageTest.cc * test/DHTRoutingTableTest.cc
Diffstat (limited to 'src/DHTMessageFactoryImpl.cc')
-rw-r--r--src/DHTMessageFactoryImpl.cc19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/DHTMessageFactoryImpl.cc b/src/DHTMessageFactoryImpl.cc
index e2621708..f1985335 100644
--- a/src/DHTMessageFactoryImpl.cc
+++ b/src/DHTMessageFactoryImpl.cc
@@ -33,6 +33,10 @@
*/
/* copyright --> */
#include "DHTMessageFactoryImpl.h"
+
+#include <cstring>
+#include <utility>
+
#include "LogFactory.h"
#include "DlAbortEx.h"
#include "Data.h"
@@ -60,8 +64,6 @@
#include "Peer.h"
#include "Logger.h"
#include "StringFormat.h"
-#include <cstring>
-#include <utility>
namespace aria2 {
@@ -135,13 +137,6 @@ void DHTMessageFactoryImpl::validateID(const Data* id) const
}
}
-void DHTMessageFactoryImpl::validateIDMatch(const unsigned char* expected, const unsigned char* actual) const
-{
- if(memcmp(expected, actual, DHT_ID_LENGTH) != 0) {
- //throw DlAbortEx("Different ID received.");
- }
-}
-
void DHTMessageFactoryImpl::validatePort(const Data* i) const
{
if(!i->isNumber()) {
@@ -202,7 +197,8 @@ SharedHandle<DHTMessage> DHTMessageFactoryImpl::createQueryMessage(const Diction
SharedHandle<DHTMessage>
DHTMessageFactoryImpl::createResponseMessage(const std::string& messageType,
const Dictionary* d,
- const SharedHandle<DHTNode>& remoteNode)
+ const std::string& ipaddr,
+ uint16_t port)
{
const Data* t = getData(d, DHTMessage::T);
const Data* y = getData(d, DHTMessage::Y);
@@ -225,7 +221,8 @@ DHTMessageFactoryImpl::createResponseMessage(const std::string& messageType,
const Dictionary* r = getDictionary(d, DHTResponseMessage::R);
const Data* id = getData(r, DHTMessage::ID);
validateID(id);
- validateIDMatch(remoteNode->getID(), id->getData());
+ SharedHandle<DHTNode> remoteNode = getRemoteNode(id->getData(), ipaddr, port);
+
std::string transactionID = t->toString();
if(messageType == DHTPingReplyMessage::PING) {
return createPingReplyMessage(remoteNode,