mirror of
https://github.com/aria2/aria2.git
synced 2025-04-07 06:27:37 +03:00
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}
This commit is contained in:
parent
0bce06348e
commit
0f13363229
209 changed files with 14405 additions and 117 deletions
48
test/XORCloserTest.cc
Normal file
48
test/XORCloserTest.cc
Normal file
|
@ -0,0 +1,48 @@
|
|||
#include "XORCloser.h"
|
||||
#include "Exception.h"
|
||||
#include "Util.h"
|
||||
#include "DHTNodeLookupEntry.h"
|
||||
#include "DHTNode.h"
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
class XORCloserTest:public CppUnit::TestFixture {
|
||||
|
||||
CPPUNIT_TEST_SUITE(XORCloserTest);
|
||||
CPPUNIT_TEST(testOperator);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
public:
|
||||
void setUp() {}
|
||||
|
||||
void tearDown() {}
|
||||
|
||||
void testOperator();
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(XORCloserTest);
|
||||
|
||||
void XORCloserTest::testOperator()
|
||||
{
|
||||
const size_t NUM_KEY = 6;
|
||||
unsigned char keys[NUM_KEY][DHT_ID_LENGTH];
|
||||
memset(keys, 0, 6*DHT_ID_LENGTH);
|
||||
|
||||
keys[0][0] = 0xf0;
|
||||
keys[1][0] = 0xb0;
|
||||
keys[2][0] = 0xa0;
|
||||
keys[3][0] = 0x80;
|
||||
keys[4][0] = 0x00;
|
||||
keys[4][DHT_ID_LENGTH-1] = 0x01;
|
||||
keys[5][0] = 0x00;
|
||||
|
||||
deque<unsigned char*> l(&keys[0], &keys[NUM_KEY]);
|
||||
|
||||
std::sort(l.begin(), l.end(), XORCloser(keys[2], DHT_ID_LENGTH));
|
||||
|
||||
CPPUNIT_ASSERT(memcmp(keys[2], l[0], DHT_ID_LENGTH) == 0);
|
||||
CPPUNIT_ASSERT(memcmp(keys[1], l[1], DHT_ID_LENGTH) == 0);
|
||||
CPPUNIT_ASSERT(memcmp(keys[3], l[2], DHT_ID_LENGTH) == 0);
|
||||
CPPUNIT_ASSERT(memcmp(keys[0], l[3], DHT_ID_LENGTH) == 0);
|
||||
CPPUNIT_ASSERT(memcmp(keys[5], l[4], DHT_ID_LENGTH) == 0);
|
||||
CPPUNIT_ASSERT(memcmp(keys[4], l[5], DHT_ID_LENGTH) == 0);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue