aria2/test/MockDHTMessageFactory.h
Tatsuhiro Tsujikawa 0f13363229 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}
2008-02-01 17:36:33 +00:00

117 lines
2.7 KiB
C++

#ifndef _D_MOCK_DHT_MESSAGE_FACTORY_H_
#define _D_MOCK_DHT_MESSAGE_FACTORY_H_
#include "DHTMessageFactory.h"
#include "DHTNode.h"
#include "MockDHTMessage.h"
#include "Dictionary.h"
#include "Data.h"
class MockDHTMessageFactory:public DHTMessageFactory {
private:
DHTNodeHandle _localNode;
public:
MockDHTMessageFactory() {}
virtual ~MockDHTMessageFactory() {}
virtual DHTMessageHandle
createQueryMessage(const Dictionary* d,
const string& ipaddr, uint16_t port)
{
return 0;
}
virtual DHTMessageHandle
createResponseMessage(const string& messageType,
const Dictionary* d,
const DHTNodeHandle& remoteNode)
{
MockDHTMessageHandle m = new MockDHTMessage(_localNode, remoteNode,
reinterpret_cast<const Data*>(d->get("t"))->toString());
m->setReply(true);
return m;
}
virtual DHTMessageHandle
createPingMessage(const DHTNodeHandle& remoteNode,
const string& transactionID = "")
{
return 0;
}
virtual DHTMessageHandle
createPingReplyMessage(const DHTNodeHandle& remoteNode,
const unsigned char* remoteNodeID,
const string& transactionID)
{
return 0;
}
virtual DHTMessageHandle
createFindNodeMessage(const DHTNodeHandle& remoteNode,
const unsigned char* targetNodeID,
const string& transactionID = "")
{
return 0;
}
virtual DHTMessageHandle
createFindNodeReplyMessage(const DHTNodeHandle& remoteNode,
const DHTNodes& closestKNodes,
const string& transactionID)
{
return 0;
}
virtual DHTMessageHandle
createGetPeersMessage(const DHTNodeHandle& remoteNode,
const unsigned char* infoHash,
const string& transactionID)
{
return 0;
}
virtual DHTMessageHandle
createGetPeersReplyMessage(const DHTNodeHandle& remoteNode,
const DHTNodes& closestKNodes,
const string& transactionID,
const string& token = "")
{
return 0;
}
virtual DHTMessageHandle
createGetPeersReplyMessage(const DHTNodeHandle& remoteNode,
const Peers& peers,
const string& transactionID,
const string& token = "")
{
return 0;
}
virtual DHTMessageHandle
createAnnouncePeerMessage(const DHTNodeHandle& remoteNode,
const unsigned char* infoHash,
uint16_t tcpPort,
const string& token,
const string& transactionID = "")
{
return 0;
}
virtual DHTMessageHandle
createAnnouncePeerReplyMessage(const DHTNodeHandle& remoteNode,
const string& transactionID)
{
return 0;
}
void setLocalNode(const DHTNodeHandle& node)
{
_localNode = node;
}
};
typedef SharedHandle<MockDHTMessageFactory> MockDHTMessageFactoryHandle;
#endif // _D_MOCK_DHT_MESSAGE_FACTORY_H_