Add --peer-agent option

Add --peer-agent for setting the version/user agent used in the extended
handshake protocol for bittorrent.
This commit is contained in:
Kurt Kartaltepe 2017-06-23 15:39:46 -05:00
parent 88ab6ba23c
commit a3bacc0ff1
9 changed files with 50 additions and 1 deletions

View file

@ -42,6 +42,7 @@ class BittorrentHelperTest : public CppUnit::TestFixture {
CPPUNIT_TEST(testGetPieceLength);
CPPUNIT_TEST(testGetInfoHashAsString);
CPPUNIT_TEST(testGetPeerId);
CPPUNIT_TEST(testGetPeerAgent);
CPPUNIT_TEST(testComputeFastSet);
CPPUNIT_TEST(testGetFileEntries_multiFileUrlList);
CPPUNIT_TEST(testGetFileEntries_singleFileUrlList);
@ -100,6 +101,7 @@ public:
void testGetPieceLength();
void testGetInfoHashAsString();
void testGetPeerId();
void testGetPeerAgent();
void testComputeFastSet();
void testGetFileEntries_multiFileUrlList();
void testGetFileEntries_singleFileUrlList();
@ -325,6 +327,13 @@ void BittorrentHelperTest::testGetPeerId()
CPPUNIT_ASSERT_EQUAL((size_t)20, peerId.size());
}
void BittorrentHelperTest::testGetPeerAgent()
{
std::string peerAgent = generateStaticPeerAgent("aria2/-1.-1.-1");
CPPUNIT_ASSERT_EQUAL(std::string("aria2/-1.-1.-1"), peerAgent);
CPPUNIT_ASSERT_EQUAL(std::string("aria2/-1.-1.-1"), bittorrent::getStaticPeerAgent());
}
void BittorrentHelperTest::testComputeFastSet()
{
std::string ipaddr = "192.168.0.1";