diff --git a/ChangeLog b/ChangeLog index 1aaa62f4..322630ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-06-08 Tatsuhiro Tsujikawa + + Drop connection if the incoming peer ID is the same with localhost's + one. The previous implementation drops connection when incoming peer's + IP address is the same with localhost's one. + * src/PeerListenCommand.cc + * src/DefaultBtInteractive.cc + 2008-06-08 Tatsuhiro Tsujikawa Returns cached data without checking whether socket is readable diff --git a/src/DefaultBtInteractive.cc b/src/DefaultBtInteractive.cc index 5efb6ba1..a1b45c47 100644 --- a/src/DefaultBtInteractive.cc +++ b/src/DefaultBtInteractive.cc @@ -65,6 +65,7 @@ #include "Logger.h" #include "LogFactory.h" #include "StringFormat.h" +#include namespace aria2 { @@ -97,6 +98,10 @@ BtMessageHandle DefaultBtInteractive::receiveHandshake(bool quickReply) { if(message.isNull()) { return SharedHandle(); } + if(memcmp(message->getPeerId(), btContext->getPeerId(), PEER_ID_LENGTH) == 0) { + throw DlAbortEx(StringFormat("CUID#%d - Drop connection from the same Peer ID", cuid).str()); + } + peer->setPeerId(message->getPeerId()); if(message->isFastExtensionSupported()) { diff --git a/src/PeerListenCommand.cc b/src/PeerListenCommand.cc index 2a037f48..2ec15145 100644 --- a/src/PeerListenCommand.cc +++ b/src/PeerListenCommand.cc @@ -96,12 +96,7 @@ bool PeerListenCommand::execute() { peerSocket.reset(socket->acceptConnection()); std::pair peerInfo; peerSocket->getPeerInfo(peerInfo); - std::pair localInfo; - peerSocket->getAddrInfo(localInfo); - if(peerInfo.first == localInfo.first) { - continue; - } // Since peerSocket may be in non-blocking mode, make it blocking mode // here. peerSocket->setBlockingMode();