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
pull/1/head
Tatsuhiro Tsujikawa 2008-06-08 10:27:57 +00:00
parent 249194ba8d
commit 725f68b0c6
3 changed files with 13 additions and 5 deletions

View File

@ -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

View File

@ -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()) {

View File

@ -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();