Sfoglia il codice sorgente

2008-06-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

	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
Tatsuhiro Tsujikawa 17 anni fa
parent
commit
725f68b0c6
3 ha cambiato i file con 13 aggiunte e 5 eliminazioni
  1. 8 0
      ChangeLog
  2. 5 0
      src/DefaultBtInteractive.cc
  3. 0 5
      src/PeerListenCommand.cc

+ 8 - 0
ChangeLog

@@ -1,3 +1,11 @@
+2008-06-08  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
+
+	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  <tujikawa at rednoah dot com>
 
 	Returns cached data without checking whether socket is readable

+ 5 - 0
src/DefaultBtInteractive.cc

@@ -65,6 +65,7 @@
 #include "Logger.h"
 #include "LogFactory.h"
 #include "StringFormat.h"
+#include <cstring>
 
 namespace aria2 {
 
@@ -97,6 +98,10 @@ BtMessageHandle DefaultBtInteractive::receiveHandshake(bool quickReply) {
   if(message.isNull()) {
     return SharedHandle<BtMessage>();
   }
+  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()) {

+ 0 - 5
src/PeerListenCommand.cc

@@ -96,12 +96,7 @@ bool PeerListenCommand::execute() {
       peerSocket.reset(socket->acceptConnection());
       std::pair<std::string, uint16_t> peerInfo;
       peerSocket->getPeerInfo(peerInfo);
-      std::pair<std::string, uint16_t> 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();