From 0f133632298e31dab0efe6fd36f00c84d2175f33 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Fri, 1 Feb 2008 17:36:33 +0000 Subject: 2008-02-01 Tatsuhiro Tsujikawa 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} --- src/DHTPingMessage.cc | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 src/DHTPingMessage.cc (limited to 'src/DHTPingMessage.cc') diff --git a/src/DHTPingMessage.cc b/src/DHTPingMessage.cc new file mode 100644 index 00000000..844a4a9e --- /dev/null +++ b/src/DHTPingMessage.cc @@ -0,0 +1,70 @@ +/* */ +#include "DHTPingMessage.h" +#include "DHTNode.h" +#include "Data.h" +#include "DHTConstants.h" +#include "DHTMessageDispatcher.h" +#include "DHTMessageFactory.h" +#include "DHTMessageCallback.h" + +DHTPingMessage::DHTPingMessage(const DHTNodeHandle& localNode, + const DHTNodeHandle& remoteNode, + const string& transactionID): + DHTQueryMessage(localNode, remoteNode, transactionID) {} + +DHTPingMessage::~DHTPingMessage() {} + +void DHTPingMessage::doReceivedAction() +{ + // send back ping reply + DHTMessageHandle reply = _factory->createPingReplyMessage(_remoteNode, _localNode->getID(), _transactionID); + _dispatcher->addMessageToQueue(reply); +} + +Dictionary* DHTPingMessage::getArgument() +{ + Dictionary* a = new Dictionary(); + a->put("id", new Data(reinterpret_cast(_localNode->getID()), + DHT_ID_LENGTH)); + return a; +} + +string DHTPingMessage::getMessageType() const +{ + return "ping"; +} + +void DHTPingMessage::validate() const {} -- cgit