2006-07-16 19:39:23 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (c) 2005 Transmission authors and contributors
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2007-07-12 17:51:45 +00:00
|
|
|
#include <ctype.h> /* isprint */
|
2007-07-29 18:31:25 +00:00
|
|
|
#include <stdio.h>
|
2007-10-19 00:02:37 +00:00
|
|
|
#include <stdlib.h> /* bsearch */
|
2007-07-29 18:11:21 +00:00
|
|
|
#include <string.h>
|
2007-07-18 17:25:42 +00:00
|
|
|
|
2007-10-19 00:02:37 +00:00
|
|
|
#include <sys/types.h> /* event.h needs this */
|
|
|
|
#include <event.h>
|
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
#include "transmission.h"
|
2007-07-18 17:25:42 +00:00
|
|
|
#include "trcompat.h"
|
2007-10-19 00:02:37 +00:00
|
|
|
#include "utils.h" /* tr_strdup */
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2006-12-11 01:25:28 +00:00
|
|
|
static int charToInt( char character )
|
2006-12-11 01:23:09 +00:00
|
|
|
{
|
2006-12-16 02:39:12 +00:00
|
|
|
int value;
|
2006-12-11 01:23:09 +00:00
|
|
|
if( character >= 'A' && character <= 'Z' )
|
2006-12-16 02:39:12 +00:00
|
|
|
value = 10 + character - 'A';
|
2007-07-18 00:59:08 +00:00
|
|
|
else if( character >= 'a' && character <= 'z')
|
|
|
|
value = 36 + character - 'a';
|
2006-12-16 02:39:12 +00:00
|
|
|
else
|
|
|
|
value = character - '0';
|
2006-12-11 01:23:09 +00:00
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2007-10-19 00:02:37 +00:00
|
|
|
/*
|
|
|
|
* Azureus-style uses the following encoding: '-', two characters for client id,
|
|
|
|
* four ascii digits for version number, '-', followed by random numbers.
|
|
|
|
* For example: '-AZ2060-'...
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct az_client
|
|
|
|
{
|
|
|
|
const char * abbreviation;
|
|
|
|
int version_width[4];
|
|
|
|
const char * name;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct az_client azureus_clients[] =
|
|
|
|
{
|
|
|
|
{ "AG", { 1, 1, 1, 0 }, "Ares" },
|
|
|
|
{ "AR", { -1, -1, -1, -1 }, "Arctic Torrent" },
|
|
|
|
{ "AV", { -1, -1, -1, -1 }, "Avicora" },
|
|
|
|
{ "AX", { 2, 2, 0, 0 }, "BitPump" },
|
|
|
|
{ "AZ", { 1, 1, 1, 1 }, "Azureus" },
|
|
|
|
{ "A~", { 1, 1, 1, 0 }, "Ares" },
|
|
|
|
{ "BB", { 1, 3, 0, 0 }, "BitBuddy" },
|
|
|
|
{ "BC", { 2, 2, 0, 0 }, "BitComet" },
|
|
|
|
{ "BF", { -1, -1, -1, -1 }, "Bitflu" },
|
|
|
|
{ "BG", { 1, 1, 1, 1 }, "BTG" },
|
|
|
|
{ "BR", { 1, 1, 2, 0 }, "BitRocket" },
|
|
|
|
{ "BS", { -1, -1, -1, -1 }, "BTSlave" },
|
|
|
|
{ "BX", { -1, -1, -1, -1 }, "Bittorrent X" },
|
|
|
|
{ "CD", { 2, 2, 0, 0 }, "Enhanced CTorrent" },
|
|
|
|
{ "CT", { 1, 1, 2, 0 }, "CTorrent" },
|
|
|
|
{ "DE", { 1, 1, 1, 1 }, "DelugeTorrent" },
|
|
|
|
{ "DP", { -1, -1, -1, -1 }, "Propagate" },
|
|
|
|
{ "EB", { -1, -1, -1, -1 }, "EBit" },
|
|
|
|
{ "ES", { 1, 1, 1, 1 }, "Electric Sheep" },
|
|
|
|
{ "FT", { 4, 0, 0, 0 }, "FoxTorrent" },
|
|
|
|
{ "GR", { 1, 1, 1, 1 }, "GetRight" },
|
|
|
|
{ "GS", { 4, 0, 0, 0 }, "GSTorrent" },
|
|
|
|
{ "HL", { 1, 1, 1, 0 }, "Halite" },
|
|
|
|
{ "HN", { -1, -1, -1, -1 }, "Hydranode" },
|
|
|
|
{ "KT", { 1, 1, 1, 0 }, "KTorrent" },
|
|
|
|
{ "LH", { -1, -1, -1, -1 }, "LH-ABC" },
|
|
|
|
{ "LK", { -1, -1, -1, -1 }, "Linkage" },
|
|
|
|
{ "LP", { 2, 2, 0, 0 }, "Lphant" },
|
|
|
|
{ "LT", { 1, 1, 1, 1 }, "Libtorrent" },
|
|
|
|
{ "LW", { -1, -1, -1, -1 }, "LimeWire" },
|
|
|
|
{ "ML", { -1, -1, -1, -1 }, "MLDonkey" },
|
|
|
|
{ "MO", { -1, -1, -1, -1 }, "MonoTorrent" },
|
|
|
|
{ "MP", { -1, -1, -1, -1 }, "MooPolice" },
|
|
|
|
{ "MT", { -1, -1, -1, -1 }, "MoonlightTorrent" },
|
|
|
|
{ "PD", { 1, 1, 1, 1 }, "Pando" },
|
|
|
|
{ "QD", { -1, -1, -1, -1 }, "QQDownload" },
|
|
|
|
{ "QT", { -1, -1, -1, -1 }, "Qt 4 Torrent Example" },
|
|
|
|
{ "RT", { -1, -1, -1, -1 }, "Retriever" },
|
|
|
|
{ "SB", { -1, -1, -1, -1 }, "Swiftbit" },
|
|
|
|
{ "SN", { -1, -1, -1, -1 }, "ShareNet" },
|
|
|
|
{ "SS", { -1, -1, -1, -1 }, "SwarmScope" },
|
|
|
|
{ "ST", { -1, -1, -1, -1 }, "SymTorrent" },
|
|
|
|
{ "SZ", { 1, 1, 1, 1 }, "Shareaza" },
|
|
|
|
{ "S~", { 1, 1, 1, 1 }, "Shareaza (beta)" },
|
|
|
|
{ "TN", { -1, -1, -1, -1 }, "Torrent.Net" },
|
|
|
|
{ "TR", { 1, 2, 1, 0 }, "Transmission" },
|
|
|
|
{ "TS", { 1, 1, 1, 1 }, "TorrentStorm" },
|
|
|
|
{ "TT", { 1, 1, 1, 1 }, "TuoTu" },
|
|
|
|
{ "UL", { -1, -1, -1, -1 }, "uLeecher" },
|
|
|
|
{ "UT", { 1, 2, 0, 0 }, "uTorrent" },
|
|
|
|
{ "WT", { -1, -1, -1, -1 }, "BitLet" },
|
|
|
|
{ "WY", { -1, -1, -1, -1 }, "FireTorrent" },
|
|
|
|
{ "XL", { -1, -1, -1, -1 }, "Xunlei" },
|
|
|
|
{ "XT", { -1, -1, -1, -1 }, "XanTorrent" },
|
|
|
|
{ "XX", { 1, 1, 2, 0 }, "Xtorrent" },
|
|
|
|
{ "ZT", { -1, -1, -1, -1 }, "ZipTorrent" },
|
|
|
|
{ "lt", { 1, 1, 1, 1 }, "libTorrent" },
|
|
|
|
{ "qB", { 1, 1, 1, 0 }, "qBittorrent" },
|
|
|
|
{ "st", { -1, -1, -1, -1 }, "sharktorrent" }
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
isStyleAzureus( const uint8_t * id )
|
|
|
|
{
|
|
|
|
return id[0]=='-' && id[7]=='-';
|
|
|
|
}
|
|
|
|
|
|
|
|
static char*
|
|
|
|
getAzureusAbbreviation( const uint8_t * id, char * setme )
|
|
|
|
{
|
|
|
|
setme[0] = id[1];
|
|
|
|
setme[1] = id[2];
|
|
|
|
setme[2] = '\0';
|
|
|
|
return setme;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
compareAzureusAbbreviations( const void * va, const void * vb )
|
|
|
|
{
|
|
|
|
const char * abbreviation = va;
|
|
|
|
const struct az_client * b = vb;
|
|
|
|
return strcmp( abbreviation, b->abbreviation );
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct az_client*
|
|
|
|
getAzureusClient( const uint8_t * peer_id )
|
|
|
|
{
|
|
|
|
const struct az_client * ret = NULL;
|
|
|
|
|
|
|
|
if( isStyleAzureus( peer_id ) )
|
|
|
|
{
|
|
|
|
char abbreviation[3];
|
|
|
|
ret = bsearch( getAzureusAbbreviation( peer_id, abbreviation ),
|
|
|
|
azureus_clients,
|
|
|
|
sizeof(azureus_clients) / sizeof(azureus_clients[0]),
|
|
|
|
sizeof(struct az_client),
|
|
|
|
compareAzureusAbbreviations );
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct generic_client
|
|
|
|
{
|
|
|
|
int offset;
|
|
|
|
char const * id;
|
|
|
|
char const * name;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct generic_client generic_clients[] =
|
|
|
|
{
|
|
|
|
{ 0, "346-", "TorrentTopia" },
|
|
|
|
{ 0, "10-------", "JVtorrent" },
|
|
|
|
{ 0, "Deadman Walking-", "Deadman" },
|
|
|
|
{ 5, "Azureus", "Azureus 2.0.3.2" },
|
|
|
|
{ 0, "DansClient", "XanTorrent" },
|
|
|
|
{ 4, "btfans", "SimpleBT" },
|
|
|
|
{ 0, "eX", "eXeem" },
|
|
|
|
{ 0, "PRC.P---", "Bittorrent Plus! II" },
|
|
|
|
{ 0, "P87.P---", "Bittorrent Plus!" },
|
|
|
|
{ 0, "S587Plus", "Bittorrent Plus!" },
|
|
|
|
{ 0, "martini", "Martini Man" },
|
|
|
|
{ 0, "Plus---", "Bittorrent Plus" },
|
|
|
|
{ 0, "turbobt", "TurboBT" },
|
|
|
|
{ 0, "a00---0", "Swarmy" },
|
|
|
|
{ 0, "a02---0", "Swarmy" },
|
|
|
|
{ 0, "T00---0", "Teeweety" },
|
|
|
|
{ 0, "BTDWV-", "Deadman Walking" },
|
|
|
|
{ 2, "BS", "BitSpirit" },
|
|
|
|
{ 0, "Pando-", "Pando" },
|
|
|
|
{ 0, "LIME", "LimeWire" },
|
|
|
|
{ 0, "btuga", "BTugaXP" },
|
|
|
|
{ 0, "oernu", "BTugaXP" },
|
|
|
|
{ 0, "Mbrst", "Burst!" },
|
|
|
|
{ 0, "PEERAPP", "PeerApp" },
|
|
|
|
{ 0, "Plus", "Plus!" },
|
|
|
|
{ 0, "-Qt-", "Qt" },
|
|
|
|
{ 0, "exbc", "BitComet" },
|
|
|
|
{ 0, "DNA", "BitTorrent DNA" },
|
|
|
|
{ 0, "-G3", "G3 Torrent" },
|
|
|
|
{ 0, "-FG", "FlashGet" },
|
|
|
|
{ 0, "-ML", "MLdonkey" },
|
|
|
|
{ 0, "XBT", "XBT" },
|
|
|
|
{ 0, "OP", "Opera" },
|
|
|
|
{ 2, "RS", "Rufus" }
|
|
|
|
};
|
|
|
|
|
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
|
|
|
char*
|
|
|
|
tr_clientForId( const uint8_t * id )
|
2006-07-16 19:39:23 +00:00
|
|
|
{
|
|
|
|
char * ret = NULL;
|
2006-12-19 03:22:46 +00:00
|
|
|
|
2007-10-19 00:02:37 +00:00
|
|
|
if( isStyleAzureus( id ) )
|
2006-07-16 19:39:23 +00:00
|
|
|
{
|
2007-10-19 00:02:37 +00:00
|
|
|
const struct az_client * client = getAzureusClient( id );
|
|
|
|
|
|
|
|
if( client != NULL )
|
2006-07-16 19:39:23 +00:00
|
|
|
{
|
2007-10-19 00:02:37 +00:00
|
|
|
struct evbuffer * buf = evbuffer_new( );
|
|
|
|
|
|
|
|
evbuffer_add_printf( buf, "%s ", client->name );
|
|
|
|
|
|
|
|
if( client->version_width[0] == -1 )
|
|
|
|
evbuffer_add( buf, id+3, 4 );
|
|
|
|
else {
|
|
|
|
int i, offset;
|
|
|
|
for( i=0, offset=3; i<4; ++i ) {
|
|
|
|
const int width = client->version_width[i];
|
|
|
|
const int isdigit = isdigit( id[offset] );
|
|
|
|
if( !width )
|
|
|
|
break;
|
|
|
|
if( offset!=3 )
|
|
|
|
evbuffer_add( buf, (isdigit?".":" "), 1 );
|
|
|
|
if( !isdigit || width==1 || offset!=3 )
|
|
|
|
evbuffer_add( buf, id+offset, width );
|
|
|
|
else{
|
|
|
|
char * tmp = tr_strndup( (char*)(id+offset), width );
|
|
|
|
evbuffer_add_printf( buf, "%d", atoi(tmp) );
|
|
|
|
tr_free( tmp );
|
|
|
|
}
|
|
|
|
offset += width;
|
|
|
|
}
|
2007-05-09 03:05:38 +00:00
|
|
|
}
|
2007-10-19 00:02:37 +00:00
|
|
|
|
|
|
|
evbuffer_add( buf, "\0", 1 );
|
|
|
|
ret = tr_strdup( (char*) EVBUFFER_DATA( buf ) );
|
|
|
|
evbuffer_free( buf );
|
2006-07-16 19:39:23 +00:00
|
|
|
}
|
2007-10-19 00:02:37 +00:00
|
|
|
else if( !memcmp( &id[1], "BF", 2 ) )
|
2006-07-16 19:39:23 +00:00
|
|
|
{
|
2007-10-19 00:02:37 +00:00
|
|
|
asprintf( &ret, "Bitflu (%d/%d/%02d)",
|
|
|
|
charToInt( id[6] ),
|
|
|
|
charToInt( id[4] ) * 10 + charToInt( id[5] ),
|
|
|
|
charToInt( id[3] ) );
|
2006-07-16 19:39:23 +00:00
|
|
|
}
|
2006-08-14 22:33:41 +00:00
|
|
|
else if( !memcmp( &id[1], "BOW", 3 ) )
|
|
|
|
{
|
2007-04-19 06:22:37 +00:00
|
|
|
if( !memcmp( &id[4], "A0C", 3 ) )
|
|
|
|
asprintf( &ret, "Bits on Wheels 1.0.6" );
|
|
|
|
else if( !memcmp( &id[4], "A0B", 3 ) )
|
|
|
|
asprintf( &ret, "Bits on Wheels 1.0.5" );
|
2007-03-16 14:28:57 +00:00
|
|
|
else
|
2007-10-19 00:02:37 +00:00
|
|
|
asprintf( &ret, "Bits on Wheels (%3.3s", id+4 );
|
2006-09-22 10:05:51 +00:00
|
|
|
}
|
2007-10-19 00:02:37 +00:00
|
|
|
if( ret )
|
2007-08-03 11:01:33 +00:00
|
|
|
{
|
2007-10-19 00:02:37 +00:00
|
|
|
fprintf( stderr, "peer_id [%8.8s] returns [%s]\n", id, ret );
|
|
|
|
return ret;
|
2007-08-03 11:01:33 +00:00
|
|
|
}
|
2007-10-19 00:02:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* generic clients */
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
const int n = sizeof(generic_clients) / sizeof(generic_clients[0]);
|
|
|
|
for( i=0; !ret && i<n; ++i ) {
|
|
|
|
const struct generic_client * client = &generic_clients[i];
|
|
|
|
if( !memcmp( id+client->offset, client->id, strlen(client->id) ) )
|
|
|
|
ret = tr_strdup( client->name );
|
2007-09-30 13:16:18 +00:00
|
|
|
}
|
2007-10-19 00:02:37 +00:00
|
|
|
|
2006-12-19 03:22:46 +00:00
|
|
|
if( ret )
|
|
|
|
return ret;
|
2006-07-16 19:39:23 +00:00
|
|
|
}
|
2006-12-19 03:22:46 +00:00
|
|
|
|
2006-12-19 16:30:34 +00:00
|
|
|
/* Tornado-style */
|
2007-02-14 16:21:59 +00:00
|
|
|
if( !memcmp( &id[4], "----", 4 ) || !memcmp( &id[4], "--0", 3 ) )
|
2006-07-16 19:39:23 +00:00
|
|
|
{
|
|
|
|
if( id[0] == 'T' )
|
|
|
|
{
|
2006-12-11 01:23:09 +00:00
|
|
|
asprintf( &ret, "BitTornado %d.%d.%d", charToInt( id[1] ),
|
2006-12-15 17:37:16 +00:00
|
|
|
charToInt( id[2] ), charToInt( id[3] ) );
|
2006-07-16 19:39:23 +00:00
|
|
|
}
|
|
|
|
else if( id[0] == 'A' )
|
|
|
|
{
|
2006-12-15 17:37:16 +00:00
|
|
|
asprintf( &ret, "ABC %d.%d.%d", charToInt( id[1] ),
|
|
|
|
charToInt( id[2] ), charToInt( id[3] ) );
|
2006-07-16 19:39:23 +00:00
|
|
|
}
|
2007-02-14 16:21:59 +00:00
|
|
|
else if( id[0] == 'R' )
|
|
|
|
{
|
|
|
|
asprintf( &ret, "Tribler %c.%c", id[1], id[2] );
|
|
|
|
}
|
2007-02-14 16:30:11 +00:00
|
|
|
else if( id[0] == 'S' )
|
|
|
|
{
|
|
|
|
asprintf( &ret, "Shad0w's Client %d.%d.%d", charToInt( id[1] ),
|
|
|
|
charToInt( id[2] ), charToInt( id[3] ) );
|
|
|
|
}
|
2006-12-19 03:22:46 +00:00
|
|
|
|
|
|
|
if( ret )
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
2006-07-16 19:39:23 +00:00
|
|
|
}
|
2006-12-19 16:30:34 +00:00
|
|
|
|
|
|
|
/* Different formatting per client */
|
2006-12-19 03:22:46 +00:00
|
|
|
if( id[0] == 'M' && id[2] == '-' && id[7] == '-' )
|
2006-07-16 19:39:23 +00:00
|
|
|
{
|
2006-12-15 06:16:20 +00:00
|
|
|
if( id[4] == '-' && id[6] == '-' )
|
|
|
|
{
|
|
|
|
asprintf( &ret, "BitTorrent %c.%c.%c", id[1], id[3], id[5] );
|
|
|
|
}
|
|
|
|
else if( id[5] == '-' )
|
|
|
|
{
|
|
|
|
asprintf( &ret, "BitTorrent %c.%c%c.%c", id[1], id[3], id[4], id[6] );
|
|
|
|
}
|
2006-12-19 03:22:46 +00:00
|
|
|
|
|
|
|
if( ret )
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
2006-08-16 01:52:20 +00:00
|
|
|
}
|
2006-12-19 03:22:46 +00:00
|
|
|
if( id[0] == 'Q' && id[2] == '-' && id[7] == '-' )
|
2006-12-16 02:27:02 +00:00
|
|
|
{
|
|
|
|
if( id[4] == '-' && id[6] == '-' )
|
|
|
|
{
|
|
|
|
asprintf( &ret, "Queen Bee %c.%c.%c", id[1], id[3], id[5] );
|
|
|
|
}
|
|
|
|
else if( id[5] == '-' )
|
|
|
|
{
|
|
|
|
asprintf( &ret, "Queen Bee %c.%c%c.%c", id[1], id[3], id[4], id[6] );
|
|
|
|
}
|
2006-12-19 03:22:46 +00:00
|
|
|
|
|
|
|
if( ret )
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
2006-12-16 02:27:02 +00:00
|
|
|
}
|
2006-12-19 03:22:46 +00:00
|
|
|
|
|
|
|
/* All versions of each client are formatted the same */
|
|
|
|
if( !memcmp( id, "exbc", 4 ) )
|
2006-07-16 19:39:23 +00:00
|
|
|
{
|
2006-12-15 05:39:06 +00:00
|
|
|
asprintf( &ret, "%s %d.%02d",
|
|
|
|
!memcmp( &id[6], "LORD", 4 ) ? "BitLord" : "BitComet",
|
|
|
|
id[4], id[5] );
|
2006-07-16 19:39:23 +00:00
|
|
|
}
|
2006-09-12 01:38:57 +00:00
|
|
|
else if( !memcmp( id, "OP", 2 ) )
|
|
|
|
{
|
2006-09-12 01:41:17 +00:00
|
|
|
asprintf( &ret, "Opera (%c%c%c%c)", id[2], id[3], id[4], id[5] );
|
2006-09-12 01:38:57 +00:00
|
|
|
}
|
2006-09-22 10:05:51 +00:00
|
|
|
else if( !memcmp( id, "-ML", 3 ) )
|
|
|
|
{
|
|
|
|
asprintf( &ret, "MLDonkey %c%c%c%c%c",
|
|
|
|
id[3], id[4], id[5], id[6], id[7] );
|
|
|
|
}
|
2007-01-08 04:41:18 +00:00
|
|
|
else if( !memcmp( id, "AZ", 2 ) && !memcmp( &id[6], "BT", 2 ) )
|
|
|
|
{
|
2007-01-08 15:18:05 +00:00
|
|
|
asprintf( &ret, "BitTyrant %c.%c.%c.%c",
|
2007-01-08 04:41:18 +00:00
|
|
|
id[2], id[3], id[4], id[5] );
|
|
|
|
}
|
2006-12-20 17:26:32 +00:00
|
|
|
else if( !memcmp( id, "-FG", 3 ) )
|
|
|
|
{
|
|
|
|
asprintf( &ret, "FlashGet %d.%c%c",
|
|
|
|
charToInt( id[3] ) * 10 + charToInt( id[4] ),
|
|
|
|
id[5], id[6] );
|
|
|
|
}
|
2007-08-06 21:34:38 +00:00
|
|
|
else if( !memcmp( id, "DNA", 3 ) )
|
|
|
|
{
|
|
|
|
asprintf( &ret, "BitTorrent DNA %d.%d.%d", charToInt( id[3] ) * 10 + charToInt( id[4] ),
|
|
|
|
charToInt( id[5] ) * 10 + charToInt( id[6] ), charToInt( id[7] ) * 10 + charToInt( id[8] ) );
|
|
|
|
}
|
2006-12-22 23:34:35 +00:00
|
|
|
else if( !memcmp( id, "Plus", 4 ) )
|
|
|
|
{
|
2006-12-22 23:35:23 +00:00
|
|
|
asprintf( &ret, "Plus! v2 %c.%c%c", id[4], id[5], id[6] );
|
2006-12-22 23:34:35 +00:00
|
|
|
}
|
2006-12-15 05:39:06 +00:00
|
|
|
else if( !memcmp( id, "XBT", 3 ) )
|
|
|
|
{
|
2006-12-15 06:16:20 +00:00
|
|
|
asprintf( &ret, "XBT Client %c%c%c%s", id[3], id[4], id[5],
|
2007-05-09 02:55:10 +00:00
|
|
|
id[6] == 'd' ? " (debug)" : "" );
|
2006-12-15 05:39:06 +00:00
|
|
|
}
|
2006-12-29 02:09:16 +00:00
|
|
|
else if( !memcmp( id, "Mbrst", 5 ) )
|
|
|
|
{
|
|
|
|
asprintf( &ret, "burst! %c.%c.%c", id[5], id[7], id[9] );
|
|
|
|
}
|
2007-01-02 03:33:55 +00:00
|
|
|
else if( !memcmp( id, "btpd", 4 ) )
|
|
|
|
{
|
|
|
|
asprintf( &ret, "BT Protocol Daemon %c%c%c", id[5], id[6], id[7] );
|
|
|
|
}
|
2007-05-09 02:55:10 +00:00
|
|
|
else if( id[0] == 'Q' && !memcmp( &id[4], "--", 2 ) )
|
|
|
|
{
|
|
|
|
asprintf( &ret, "BTQueue %d.%d.%d", charToInt( id[1] ),
|
|
|
|
charToInt( id[2] ), charToInt( id[3] ) );
|
|
|
|
}
|
2007-05-21 15:25:28 +00:00
|
|
|
else if( !memcmp( id, "BLZ", 3 ) )
|
2007-05-21 15:02:11 +00:00
|
|
|
{
|
2007-05-21 15:25:28 +00:00
|
|
|
asprintf( &ret, "Blizzard Downloader %d.%d", id[3] + 1, id[4] );
|
2007-05-21 15:02:11 +00:00
|
|
|
}
|
2007-10-06 22:24:50 +00:00
|
|
|
else if( '\0' == id[0] && !memcmp( &id[1], "BS", 2 ) )
|
2007-07-15 05:02:30 +00:00
|
|
|
{
|
2007-10-06 22:24:50 +00:00
|
|
|
asprintf( &ret, "BitSpirit %u", ( id[1] == 0 ? 1 : id[1] ) );
|
2007-07-15 05:02:30 +00:00
|
|
|
}
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2006-12-19 03:22:46 +00:00
|
|
|
/* No match */
|
2006-07-16 19:39:23 +00:00
|
|
|
if( !ret )
|
|
|
|
{
|
2007-04-03 18:22:58 +00:00
|
|
|
if( isprint( id[0] ) && isprint( id[1] ) && isprint( id[2] ) &&
|
|
|
|
isprint( id[3] ) && isprint( id[4] ) && isprint( id[5] ) &&
|
|
|
|
isprint( id[6] ) && isprint( id[7] ) )
|
2006-08-14 22:59:30 +00:00
|
|
|
{
|
2006-08-14 22:27:34 +00:00
|
|
|
asprintf( &ret, "unknown client (%c%c%c%c%c%c%c%c)",
|
2006-07-16 19:39:23 +00:00
|
|
|
id[0], id[1], id[2], id[3], id[4], id[5], id[6], id[7] );
|
2006-08-14 22:59:30 +00:00
|
|
|
}
|
2006-08-14 22:27:34 +00:00
|
|
|
else
|
2006-08-14 22:59:30 +00:00
|
|
|
{
|
2007-04-06 01:52:16 +00:00
|
|
|
asprintf( &ret, "unknown client (0x%02x%02x%02x%02x%02x%02x%02x%02x)",
|
2007-04-03 18:22:58 +00:00
|
|
|
id[0], id[1], id[2], id[3], id[4], id[5], id[6], id[7] );
|
2006-08-14 22:59:30 +00:00
|
|
|
}
|
2006-07-16 19:39:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|