Skip to content

Commit

Permalink
more client IDs (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefantalpalaru authored May 9, 2023
1 parent 9680fe2 commit 31b843c
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 21 deletions.
15 changes: 12 additions & 3 deletions libtransmission/clients-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,24 @@ int main(void)
{
char buf[128];

TEST_CLIENT("-ADB560-", "Advanced Download Manager 11.5.6");
TEST_CLIENT("-BL246326", "BitLord 2.4.6-326"); // Style used after BitLord 0.59
TEST_CLIENT("-BT791B-", "BitTorrent 7.9.1 (Beta)");
TEST_CLIENT("-BT791\0-", "BitTorrent 7.9.1");
TEST_CLIENT("-BW1293-", "BitTorrent Web 1.2.9"); // BitTorrent Web 1.2.9.4938 (9924)
TEST_CLIENT("-FC1013-", "FileCroc 1.0.1.3");
TEST_CLIENT("-FW6830-", "FrostWire 6.8.3");
TEST_CLIENT("-Lr10X0-", "LibreTorrent 1.0.33");
TEST_CLIENT("-MR1100-", "Miro 1.1.0.0");
TEST_CLIENT("-TR0006-", "Transmission 0.6");
TEST_CLIENT("-TR0072-", "Transmission 0.72");
TEST_CLIENT("-TR111Z-", "Transmission 1.11+");
TEST_CLIENT("-TR311Z-", "Transmission OG 3.11+");
TEST_CLIENT("-UT341\0-", "\xc2\xb5Torrent 3.4.1");
TEST_CLIENT("-WS1000-", "HTTP Seed");
TEST_CLIENT("-WW0007-", "WebTorrent 0.0.0.7");
TEST_CLIENT("O1008132", "Osprey 1.0.0");
TEST_CLIENT("TIX0193-", "Tixati 1.93");
TEST_CLIENT("-UT341\0-", "\xc2\xb5Torrent 3.4.1");
TEST_CLIENT("-BT791\0-", "BitTorrent 7.9.1");
TEST_CLIENT("-BT791B-", "BitTorrent 7.9.1 (Beta)");

/* Xfplay 9.9.92 to 9.9.94 uses "-XF9992-" */
TEST_CLIENT("-XF9992-", "Xfplay 9.9.92");
Expand All @@ -44,6 +52,7 @@ int main(void)
TEST_CLIENT("-FD51R\xFF-", "Free Download Manager 5.1.27");
TEST_CLIENT("-FD51W\xFF-", "Free Download Manager 5.1.32");
TEST_CLIENT("-FD51@\xFF-", "Free Download Manager 5.1.x"); /* Negative test case */
TEST_CLIENT("FD6k4SYy9BOU4U4rk3-J", "Free Download Manager 6"); // Free Download Manager 6.17.0.4792 (9a17ce2)

/* Folx */
TEST_CLIENT("-FL51FF-", "Folx 5.x"); /* Folx v5.2.1.13690 */
Expand Down
105 changes: 92 additions & 13 deletions libtransmission/clients.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ static bool decodeBitCometClient(char* buf, size_t buflen, uint8_t const* id)

/**
* Bitcomet, and older versions of BitLord, are of the form x.yy.
* Bitcoment 1.0 and onwards are of the form x.y.
* Bitcomet 1.0 and onwards are of the form x.y.
*/
if (is_bitlord && major > 0)
{
Expand Down Expand Up @@ -208,6 +208,11 @@ char* tr_clientForId(char* buf, size_t buflen, void const* id_in)
{
tr_snprintf(buf, buflen, "Transmission 0.%02d", strint(id + 5, 2));
}
else if (strncmp(chid + 3, "3", 1) == 0 && strncmp(chid + 4, "00", 2) != 0) /* 3.00 < ID < 4.00 */
{
tr_snprintf(buf, buflen, "Transmission OG %d.%02d%s", strint(id + 3, 1), strint(id + 4, 2),
(id[6] == 'Z' || id[6] == 'X') ? "+" : "");
}
else /* current client style: -TR111Z- is 1.11+ */
{
tr_snprintf(buf, buflen, "Transmission %d.%02d%s", strint(id + 3, 1), strint(id + 4, 2),
Expand All @@ -229,6 +234,11 @@ char* tr_clientForId(char* buf, size_t buflen, void const* id_in)
tr_snprintf(buf, buflen, "BitTorrent %d.%d.%d%s", strint(id + 3, 1), strint(id + 4, 1), strint(id + 5, 1),
getMnemonicEnd(id[6]));
}
else if (strncmp(chid + 1, "BW", 2) == 0)
{
tr_snprintf(buf, buflen, "BitTorrent Web %d.%d.%d%s", strint(id + 3, 1), strint(id + 4, 1), strint(id + 5, 1),
getMnemonicEnd(id[6]));
}
else if (strncmp(chid + 1, "UM", 2) == 0)
{
tr_snprintf(buf, buflen, "\xc2\xb5Torrent Mac %d.%d.%d%s", strint(id + 3, 1), strint(id + 4, 1), strint(id + 5, 1),
Expand Down Expand Up @@ -268,6 +278,10 @@ char* tr_clientForId(char* buf, size_t buflen, void const* id_in)
}
}
/* */
else if (strncmp(chid + 1, "AD", 2) == 0)
{
three_digits(buf, buflen, "Advanced Download Manager", id + 3);
}
else if (strncmp(chid + 1, "AG", 2) == 0)
{
four_digits(buf, buflen, "Ares", id + 3);
Expand All @@ -284,6 +298,10 @@ char* tr_clientForId(char* buf, size_t buflen, void const* id_in)
{
four_digits(buf, buflen, "Avicora", id + 3);
}
else if (strncmp(chid + 1, "A~", 2) == 0)
{
three_digits(buf, buflen, "Ares", id + 3);
}
else if (strncmp(chid + 1, "BE", 2) == 0)
{
four_digits(buf, buflen, "BitTorrent SDK", id + 3);
Expand All @@ -296,6 +314,10 @@ char* tr_clientForId(char* buf, size_t buflen, void const* id_in)
{
four_digits(buf, buflen, "BitZilla", id + 3);
}
else if (strncmp(chid + 1, "BI", 2) == 0)
{
four_digits(buf, buflen, "BiglyBT", id + 3);
}
else if (strncmp(chid + 1, "BM", 2) == 0)
{
four_digits(buf, buflen, "BitMagnet", id + 3);
Expand All @@ -320,10 +342,6 @@ char* tr_clientForId(char* buf, size_t buflen, void const* id_in)
{
four_digits(buf, buflen, "BitWombat", id + 3);
}
else if (strncmp(chid + 1, "EB", 2) == 0)
{
four_digits(buf, buflen, "EBit", id + 3);
}
else if (strncmp(chid + 1, "DE", 2) == 0)
{
four_digits(buf, buflen, "Deluge", id + 3);
Expand All @@ -332,14 +350,30 @@ char* tr_clientForId(char* buf, size_t buflen, void const* id_in)
{
four_digits(buf, buflen, "Propagate Data Client", id + 3);
}
else if (strncmp(chid + 1, "EB", 2) == 0)
{
four_digits(buf, buflen, "EBit", id + 3);
}
else if (strncmp(chid + 1, "FC", 2) == 0)
{
four_digits(buf, buflen, "FileCroc", id + 3);
}
else if (strncmp(chid + 1, "FG", 2) == 0)
{
two_major_two_minor(buf, buflen, "FlashGet", id + 3);
}
else if (strncmp(chid + 1, "FT", 2) == 0)
{
four_digits(buf, buflen, "FoxTorrent/RedSwoosh", id + 3);
}
else if (strncmp(chid + 1, "FW", 2) == 0)
{
three_digits(buf, buflen, "FrostWire", id + 3);
}
else if (strncmp(chid + 1, "FX", 2) == 0)
{
four_digits(buf, buflen, "Freebox", id + 3);
}
else if (strncmp(chid + 1, "GR", 2) == 0)
{
four_digits(buf, buflen, "GetRight", id + 3);
Expand Down Expand Up @@ -368,9 +402,9 @@ char* tr_clientForId(char* buf, size_t buflen, void const* id_in)
{
four_digits(buf, buflen, "LH-ABC", id + 3);
}
else if (strncmp(chid + 1, "NX", 2) == 0)
else if (strncmp(chid + 1, "Lr", 2) == 0)
{
four_digits(buf, buflen, "Net Transport", id + 3);
three_digits(buf, buflen, "LibreTorrent", id + 3);
}
else if (strncmp(chid + 1, "MK", 2) == 0)
{
Expand All @@ -388,6 +422,10 @@ char* tr_clientForId(char* buf, size_t buflen, void const* id_in)
{
four_digits(buf, buflen, "Moonlight", id + 3);
}
else if (strncmp(chid + 1, "NX", 2) == 0)
{
four_digits(buf, buflen, "Net Transport", id + 3);
}
else if (strncmp(chid + 1, "OS", 2) == 0)
{
four_digits(buf, buflen, "OneSwarm", id + 3);
Expand All @@ -396,6 +434,10 @@ char* tr_clientForId(char* buf, size_t buflen, void const* id_in)
{
four_digits(buf, buflen, "OmegaTorrent", id + 3);
}
else if (strncmp(chid + 1, "Pando", 5) == 0)
{
no_version(buf, buflen, "Pando");
}
else if (strncmp(chid + 1, "PD", 2) == 0)
{
four_digits(buf, buflen, "Pando", id + 3);
Expand All @@ -404,6 +446,10 @@ char* tr_clientForId(char* buf, size_t buflen, void const* id_in)
{
four_digits(buf, buflen, "QQDownload", id + 3);
}
else if (strncmp(chid + 1, "QT", 2) == 0)
{
four_digits(buf, buflen, "QT 4 Torrent example", id + 3);
}
else if (strncmp(chid + 1, "RS", 2) == 0)
{
four_digits(buf, buflen, "Rufus", id + 3);
Expand All @@ -416,6 +462,10 @@ char* tr_clientForId(char* buf, size_t buflen, void const* id_in)
{
four_digits(buf, buflen, "RezTorrent", id + 3);
}
else if (strncmp(chid + 1, "SB", 2) == 0)
{
four_digits(buf, buflen, "~Swiftbit", id + 3);
}
else if (strncmp(chid + 1, "SD", 2) == 0)
{
four_digits(buf, buflen, "Thunder", id + 3);
Expand Down Expand Up @@ -444,6 +494,10 @@ char* tr_clientForId(char* buf, size_t buflen, void const* id_in)
{
four_digits(buf, buflen, "SharkTorrent", id + 3);
}
else if (strncmp(chid + 1, "TB", 2) == 0)
{
no_version(buf, buflen, "Torch Browser");
}
else if (strncmp(chid + 1, "TN", 2) == 0)
{
four_digits(buf, buflen, "Torrent .NET", id + 3);
Expand All @@ -464,10 +518,22 @@ char* tr_clientForId(char* buf, size_t buflen, void const* id_in)
{
four_digits(buf, buflen, "Vagaa", id + 3);
}
else if (strncmp(chid + 1, "WS", 2) == 0)
{
no_version(buf, buflen, "HTTP Seed");
}
else if (strncmp(chid + 1, "WT-", 3) == 0)
{
no_version(buf, buflen, "BitLet");
}
else if (strncmp(chid + 1, "WT", 2) == 0)
{
four_digits(buf, buflen, "BitLet", id + 3);
}
else if (strncmp(chid + 1, "WW", 2) == 0)
{
four_digits(buf, buflen, "WebTorrent", id + 3);
}
else if (strncmp(chid + 1, "WY", 2) == 0)
{
four_digits(buf, buflen, "FireTorrent", id + 3);
Expand All @@ -488,14 +554,14 @@ char* tr_clientForId(char* buf, size_t buflen, void const* id_in)
{
four_digits(buf, buflen, "Xtorrent", id + 3);
}
else if (strncmp(chid + 1, "ZT", 2) == 0)
{
four_digits(buf, buflen, "Zip Torrent", id + 3);
}
else if (strncmp(chid + 1, "ZO", 2) == 0)
{
four_digits(buf, buflen, "Zona", id + 3);
}
else if (strncmp(chid + 1, "ZT", 2) == 0)
{
four_digits(buf, buflen, "Zip Torrent", id + 3);
}
/* */
else if (strncmp(chid + 1, "A~", 2) == 0)
{
Expand Down Expand Up @@ -642,6 +708,11 @@ char* tr_clientForId(char* buf, size_t buflen, void const* id_in)
tr_snprintf(buf, buflen, "\xc2\xb5Torrent %d.%d.%d%s", strint(id + 3, 1), strint(id + 4, 1), strint(id + 5, 2),
getMnemonicEnd(id[7]));
}
else if (strncmp(chid + 1, "UW", 2) == 0)
{
tr_snprintf(buf, buflen, "\xc2\xb5Torrent Web %d.%d.%d%s", strint(id + 3, 1), strint(id + 4, 1), strint(id + 5, 2),
getMnemonicEnd(id[7]));
}
else if (strncmp(chid + 1, "UM", 2) == 0)
{
tr_snprintf(buf, buflen, "\xc2\xb5Torrent Mac %d.%d.%d%s", strint(id + 3, 1), strint(id + 4, 1), strint(id + 5, 2),
Expand Down Expand Up @@ -724,6 +795,10 @@ char* tr_clientForId(char* buf, size_t buflen, void const* id_in)
{
no_version(buf, buflen, "eXeem");
}
else if (strncmp(chid, "A2", 2) == 0)
{
no_version(buf, buflen, "aria2");
}
else if (strncmp(chid, "aria2-", 6) == 0)
{
no_version(buf, buflen, "aria2");
Expand All @@ -732,11 +807,15 @@ char* tr_clientForId(char* buf, size_t buflen, void const* id_in)
{
no_version(buf, buflen, "BitLet");
}
else if (strncmp(chid, "-FG", 3) == 0)
else if (strncmp(chid, "FD6", 3) == 0)
{
two_major_two_minor(buf, buflen, "FlashGet", id + 3);
no_version(buf, buflen, "Free Download Manager 6");
}
/* Everything else */
else if (strncmp(chid, "-BL", 3) == 0)
{
tr_snprintf(buf, buflen, "BitLord %c.%c.%c-%c%c%c", id[3], id[4], id[5], id[6], id[7], id[8]);
}
else if (strncmp(chid, "S3", 2) == 0 && id[2] == '-' && id[4] == '-' && id[6] == '-')
{
tr_snprintf(buf, buflen, "Amazon S3 %c.%c.%c", id[3], id[5], id[7]);
Expand Down
2 changes: 2 additions & 0 deletions libtransmission/handshake.c
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,8 @@ static ReadState readPeerId(tr_handshake* handshake, struct evbuffer* inbuf)
tr_clientForId(client, sizeof(client), peer_id);
dbgmsg(handshake, "peer-id is [%s] ... isIncoming is %d", client, tr_peerIoIsIncoming(handshake->io));

/*fprintf(stderr, "peer-id is [%s] (%20.20s)\n", client, peer_id);*/

/* if we've somehow connected to ourselves, don't keep the connection */
tor = tr_torrentFindFromHash(handshake->session, tr_peerIoGetTorrentHash(handshake->io));
connected_to_self = tor != NULL && memcmp(peer_id, tr_torrentGetPeerId(tor), PEER_ID_LEN) == 0;
Expand Down
4 changes: 2 additions & 2 deletions libtransmission/peer-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1000,11 +1000,11 @@ void tr_peerIoSetPeersId(tr_peerIo* io, uint8_t const* peer_id)

if ((io->peerIdIsSet = peer_id != NULL))
{
memcpy(io->peerId, peer_id, 20);
memcpy(io->peerId, peer_id, PEER_ID_LEN);
}
else
{
memset(io->peerId, '\0', 20);
memset(io->peerId, '\0', PEER_ID_LEN);
}
}

Expand Down
6 changes: 3 additions & 3 deletions libtransmission/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

#define PEERID_PREFIX "-TR301Z-"
#define USERAGENT_PREFIX "3.01+"
#define VCS_REVISION "dfb5f73eaa"
#define VCS_REVISION_NUM dfb5f73eaa
#define VCS_REVISION "9680fe2e24"
#define VCS_REVISION_NUM 9680fe2e24
#define SHORT_VERSION_STRING "3.01+"
#define LONG_VERSION_STRING "3.01+ (dfb5f73eaa)"
#define LONG_VERSION_STRING "3.01+ (9680fe2e24)"
#define VERSION_STRING_INFOPLIST 3.01+
#define BUILD_STRING_INFOPLIST 14714.3.1
#define MAJOR_VERSION 3
Expand Down

0 comments on commit 31b843c

Please sign in to comment.