summaryrefslogtreecommitdiff
path: root/src/PeerInteractionCommand.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-02-01 17:36:33 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-02-01 17:36:33 +0000
commit0f133632298e31dab0efe6fd36f00c84d2175f33 (patch)
tree0e9effc84f05b47e3a6c6ec4a9f7b38391d8be86 /src/PeerInteractionCommand.cc
parent0bce06348e3be57c97e246d2a7af71683dc76ede (diff)
2008-02-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added DHT functionality, compatible with mainline. DHT is disabled by default. To enable it, give --enable-dht to aria2c. You may need to specify entry point to DHT network using --dht-entry-point. DHT uses UDP port to listen incoming message. Use --dht-listen-port to specify port number. Make sure that your firewall configuration can pass through UDP traffic to the port. The routing table is saved in $HOME/.aria2/dht.dat. * src/DHT* * src/BNode.{h, cc} * src/PeerInteractionCommand.cc: enable DHT functionality for a particular torrent. * src/Data.cc: Rewritten ctor. * src/OptionHandlerFactory.cc: Added --enable-dht, --dht-listen-port, --dht-entry-point. * src/DefaultBtInteractive.cc: Send port message if dht is enabled. * src/RequestGroup.cc: Initialize DHT functionality. When download ends, remove BtContext from DHTPeerAnnounceStorage. * src/BtPortMessage.{h, cc}: Rewritten. * src/message.h * src/OptionHandlerImpl.cc * src/option_processing.cc: Added --enable-dht, --dht-listen-port, --dht-entry-point. * src/Dictionary.{h, cc} (remove): New function. * src/prefs.h * src/DefaultBtMessageFactory.h * src/BtHandshakeMessage.cc * src/ActivePeerConnectionCommand.cc * src/SocketCore.{h, cc}: Added datagram socket support. * src/DefaultBtMessageFactory.cc * src/BtSetup.cc: Add BtContext to DHTPeerAnnounceStorage here. Create DHT commands. * src/BtMessageFactory.h * src/PeerMessageUtil.{h, cc}
Diffstat (limited to 'src/PeerInteractionCommand.cc')
-rw-r--r--src/PeerInteractionCommand.cc18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/PeerInteractionCommand.cc b/src/PeerInteractionCommand.cc
index 2cd64a27..3a60b6b7 100644
--- a/src/PeerInteractionCommand.cc
+++ b/src/PeerInteractionCommand.cc
@@ -47,6 +47,11 @@
#include "DefaultBtMessageFactory.h"
#include "DefaultBtInteractive.h"
#include "CUIDCounter.h"
+#include "DHTTaskQueue.h"
+#include "DHTTaskFactory.h"
+#include "DHTNode.h"
+#include "DHTSetup.h"
+#include "DHTRegistry.h"
#include <algorithm>
PeerInteractionCommand::PeerInteractionCommand(int32_t cuid,
@@ -74,6 +79,8 @@ PeerInteractionCommand::PeerInteractionCommand(int32_t cuid,
factory->setCuid(cuid);
factory->setBtContext(btContext);
factory->setPeer(peer);
+ factory->setTaskQueue(DHTRegistry::_taskQueue);
+ factory->setTaskFactory(DHTRegistry::_taskFactory);
PeerConnectionHandle peerConnection = passedPeerConnection.isNull() ?
new PeerConnection(cuid, socket, e->option) : passedPeerConnection;
@@ -112,8 +119,15 @@ PeerInteractionCommand::PeerInteractionCommand(int32_t cuid,
btInteractive->setKeepAliveInterval(e->option->getAsInt(PREF_BT_KEEP_ALIVE_INTERVAL));
btInteractive->setMaxDownloadSpeedLimit(e->option->getAsInt(PREF_MAX_DOWNLOAD_LIMIT));
btInteractive->setBtMessageFactory(factory);
- if(!btContext->isPrivate() && e->option->getAsBool(PREF_ENABLE_PEER_EXCHANGE)) {
- btInteractive->setUTPexEnabled(true);
+ if(!btContext->isPrivate()) {
+ if(e->option->getAsBool(PREF_ENABLE_PEER_EXCHANGE)) {
+ btInteractive->setUTPexEnabled(true);
+ }
+ if(DHTSetup::initialized()) {
+ btInteractive->setDHTEnabled(true);
+ btInteractive->setLocalNode(DHTRegistry::_localNode);
+ factory->setDHTEnabled(true);
+ }
}
this->btInteractive = btInteractive;