summaryrefslogtreecommitdiff
path: root/src/PeerReceiveHandshakeCommand.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2007-12-22 03:57:55 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2007-12-22 03:57:55 +0000
commit286f34cb3f350c9884a96d5ea3e20e2a3bbf0c37 (patch)
treec33aebf51947efaa5713b2dae00464e86e391442 /src/PeerReceiveHandshakeCommand.cc
parentc25f4cffc0fec4fcf657aff0c204baaac0bbe6f7 (diff)
2007-12-22 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added uTorrent compatible Peer Exchange. * src/BencodeVisitor.{h, cc} * test/BencodeVisitorTest.cc * src/BtConstants.h * src/BtContext.h: Added 'private' flag. * src/BtExtendedMessage.{h, cc} * test/BtExtendedMessageTest.cc * src/BtHandshakeMessage.{h, cc}: Set extended messaging bit in reserved field. * test/BtHandshakeMessageTest.cc * src/BtMessageFactory.h * src/BtRegistry.h * src/BtRuntime.h: This class holds default extension message IDs for aria2. By default, aria2 uses ID 8 for ut_pex. * src/DefaultBtContext.cc * src/DefaultBtInteractive.{h, cc}: This class holds _utPexEnabled. When it is true, aria2 enables ut_pex. This value is set by PeerInteractionCommand. * src/DefaultBtMessageFactory.{h, cc} * test/DefaultBtMessageFactoryTest.cc * src/DefaultBtMessageReceiver.cc: Moved the code of fast extension handling to DefaultBtInteractive class. * src/DefaultExtensionMessageFactory.{h, cc} * test/DefaultExtensionMessageFactoryTest.cc * src/DefaultPeerStorage.cc: Returns false if a peer is already in the container(peers and incomingPeers. The equality is determined by Peer::id). * test/DefaultPeerStorageTest.cc * src/ExtensionMessage.h * test/MockExtensionMessage.h * src/ExtensionMessageFactory.h * test/MockExtensionMessageFactory.h * src/HandshakeExtensionMessage.{h, cc} * test/HandshakeExtensionMessageTest.cc * src/MetaEntry.h * src/Peer.{h, cc} * src/PeerInteractionCommand.cc * src/PeerReceiveHandshakeCommand.cc: Evaluate the return value of addIncomingPeer. * src/PeerMessageUtil.{h, cc} * src/PeerObject.h * src/UTPexExtensionMessage.{h, cc} * test/UTPexExtensionMessageTest.cc * src/message.h * src/prefs.h Fixed the bug that returns incomplete data when it contains null character. A convenient constructor was also added. * src/Data.{h, cc} Rewritten. * src/CompactPeerListProcessor.cc Fixed typos. * src/message.h * src/MetaFileUtil.cc
Diffstat (limited to 'src/PeerReceiveHandshakeCommand.cc')
-rw-r--r--src/PeerReceiveHandshakeCommand.cc29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/PeerReceiveHandshakeCommand.cc b/src/PeerReceiveHandshakeCommand.cc
index 81d9fb72..edb19756 100644
--- a/src/PeerReceiveHandshakeCommand.cc
+++ b/src/PeerReceiveHandshakeCommand.cc
@@ -77,21 +77,22 @@ bool PeerReceiveHandshakeCommand::executeInternal()
if(!PIECE_STORAGE(btContext)->downloadFinished() && tstat.getDownloadSpeed() < _lowestSpeedLimit ||
BT_RUNTIME(btContext)->getConnections() < MAX_PEERS) {
peer->reconfigure(btContext->getPieceLength(), btContext->getTotalLength());
- PEER_STORAGE(btContext)->addIncomingPeer(peer);
+ if(PEER_STORAGE(btContext)->addIncomingPeer(peer)) {
- peer->cuid = cuid;
-
- PeerInteractionCommand* command =
- new PeerInteractionCommand(cuid,
- btContext->getOwnerRequestGroup(),
- peer,
- e,
- btContext,
- socket,
- PeerInteractionCommand::RECEIVER_WAIT_HANDSHAKE,
- _peerConnection);
- e->commands.push_back(command);
- logger->debug(MSG_INCOMING_PEER_CONNECTION, cuid, peer->cuid);
+ peer->cuid = cuid;
+
+ PeerInteractionCommand* command =
+ new PeerInteractionCommand(cuid,
+ btContext->getOwnerRequestGroup(),
+ peer,
+ e,
+ btContext,
+ socket,
+ PeerInteractionCommand::RECEIVER_WAIT_HANDSHAKE,
+ _peerConnection);
+ e->commands.push_back(command);
+ logger->debug(MSG_INCOMING_PEER_CONNECTION, cuid, peer->cuid);
+ }
}
return true;
} else {