1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 01:27:28 +00:00

better identification of clients with weird formats that might conflict with others

This commit is contained in:
Mitchell Livingston 2006-12-19 03:22:46 +00:00
parent 46cef6d780
commit 38b3198613

View file

@ -41,6 +41,7 @@ char * tr_clientForId( uint8_t * id )
{ {
char * ret = NULL; char * ret = NULL;
/* Azureus style */
if( id[0] == '-' && id[7] == '-' ) if( id[0] == '-' && id[7] == '-' )
{ {
if( !memcmp( &id[1], "TR", 2 ) ) if( !memcmp( &id[1], "TR", 2 ) )
@ -107,8 +108,15 @@ char * tr_clientForId( uint8_t * id )
charToInt( id[3] ) * 10 + charToInt( id[4] ), charToInt( id[3] ) * 10 + charToInt( id[4] ),
charToInt( id[5] ) * 10 + charToInt( id[6] ) ); charToInt( id[5] ) * 10 + charToInt( id[6] ) );
} }
if( ret )
{
return ret;
}
} }
else if( !memcmp( &id[4], "----", 4 ) || !memcmp( &id[4], "--00", 4 ) )
/* Different formatting per client */
if( !memcmp( &id[4], "----", 4 ) || !memcmp( &id[4], "--00", 4 ) )
{ {
if( id[0] == 'T' ) if( id[0] == 'T' )
{ {
@ -120,8 +128,13 @@ char * tr_clientForId( uint8_t * id )
asprintf( &ret, "ABC %d.%d.%d", charToInt( id[1] ), asprintf( &ret, "ABC %d.%d.%d", charToInt( id[1] ),
charToInt( id[2] ), charToInt( id[3] ) ); charToInt( id[2] ), charToInt( id[3] ) );
} }
if( ret )
{
return ret;
}
} }
else if( id[0] == 'M' && id[2] == '-' && id[7] == '-' ) if( id[0] == 'M' && id[2] == '-' && id[7] == '-' )
{ {
if( id[4] == '-' && id[6] == '-' ) if( id[4] == '-' && id[6] == '-' )
{ {
@ -131,8 +144,13 @@ char * tr_clientForId( uint8_t * id )
{ {
asprintf( &ret, "BitTorrent %c.%c%c.%c", id[1], id[3], id[4], id[6] ); asprintf( &ret, "BitTorrent %c.%c%c.%c", id[1], id[3], id[4], id[6] );
} }
if( ret )
{
return ret;
}
} }
else if( id[0] == 'Q' && id[2] == '-' && id[7] == '-' ) if( id[0] == 'Q' && id[2] == '-' && id[7] == '-' )
{ {
if( id[4] == '-' && id[6] == '-' ) if( id[4] == '-' && id[6] == '-' )
{ {
@ -142,8 +160,15 @@ char * tr_clientForId( uint8_t * id )
{ {
asprintf( &ret, "Queen Bee %c.%c%c.%c", id[1], id[3], id[4], id[6] ); asprintf( &ret, "Queen Bee %c.%c%c.%c", id[1], id[3], id[4], id[6] );
} }
if( ret )
{
return ret;
}
} }
else if( !memcmp( id, "exbc", 4 ) )
/* All versions of each client are formatted the same */
if( !memcmp( id, "exbc", 4 ) )
{ {
asprintf( &ret, "%s %d.%02d", asprintf( &ret, "%s %d.%02d",
!memcmp( &id[6], "LORD", 4 ) ? "BitLord" : "BitComet", !memcmp( &id[6], "LORD", 4 ) ? "BitLord" : "BitComet",
@ -172,6 +197,7 @@ char * tr_clientForId( uint8_t * id )
asprintf( &ret, "G3 Torrent" ); asprintf( &ret, "G3 Torrent" );
} }
/* No match */
if( !ret ) if( !ret )
{ {
if( id[0] != 0 ) if( id[0] != 0 )