Changeset 1650
- Timestamp:
- Apr 3, 2007, 6:22:58 PM (15 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/clients.c
r1648 r1650 321 321 if( !ret ) 322 322 { 323 if( id[0] != 0 ) 323 if( isprint( id[0] ) && isprint( id[1] ) && isprint( id[2] ) && 324 isprint( id[3] ) && isprint( id[4] ) && isprint( id[5] ) && 325 isprint( id[6] ) && isprint( id[7] ) ) 324 326 { 325 327 asprintf( &ret, "unknown client (%c%c%c%c%c%c%c%c)", … … 328 330 else 329 331 { 330 asprintf( &ret, "unknown client" ); 332 asprintf( &ret, "unknown client (0x%02x%02x%02x%02x%02x%02x%02x%02x", 333 id[0], id[1], id[2], id[3], id[4], id[5], id[6], id[7] ); 331 334 } 332 335 } -
trunk/libtransmission/internal.h
r1614 r1650 42 42 #include <string.h> 43 43 #include <unistd.h> 44 #include <ctype.h> 44 45 #include <errno.h> 45 46 #include <limits.h> -
trunk/libtransmission/peer.c
r1614 r1650 136 136 tr_ratecontrol_t * download; 137 137 tr_ratecontrol_t * upload; 138 139 char * client; 138 140 }; 139 141 … … 219 221 tr_rcClose( peer->download ); 220 222 tr_rcClose( peer->upload ); 223 free( peer->client ); 221 224 free( peer ); 225 } 226 227 const char * 228 tr_peerClient( tr_peer_t * peer ) 229 { 230 if( NULL == peer->client ) 231 { 232 peer->client = tr_clientForId( peer->id ); 233 } 234 235 return peer->client; 222 236 } 223 237 -
trunk/libtransmission/peer.h
r1579 r1650 32 32 tr_peer_t * tr_peerInit ( struct in_addr, in_port_t, int sock, int ); 33 33 void tr_peerDestroy ( tr_peer_t * ); 34 const char *tr_peerClient ( tr_peer_t * ); 34 35 void tr_peerSetPrivate ( tr_peer_t *, int ); 35 36 void tr_peerSetTorrent ( tr_peer_t *, tr_torrent_t * ); -
trunk/libtransmission/peeraz.h
r1612 r1650 360 360 } 361 361 362 #if 0 /* ugh, we have to deal with encoding if we do this */ 363 /* get peer's client name */ 364 sub = tr_bencDictFind( &val, "client" ); 365 sub2 = tr_bencDictFind( &val, "version" ); 366 if( NULL != sub && TYPE_STR == sub->type && 367 NULL != sub2 && TYPE_STR == sub->type ) 368 { 369 if( NULL == peer->client || 370 ( 0 != strncmp( peer->client, sub->val.s.s, sub->val.s.i ) || 371 ' ' != peer->client[sub->val.s.i] || 372 0 != strcmp( peer->client + sub->val.s.i + 1, sub2->val.s.s ) ) ) 373 { 374 client = NULL; 375 asprintf( &client, "%s %s", sub->val.s.s, sub2->val.s.s ); 376 if( NULL != client ) 377 { 378 free( peer->client ); 379 peer->client = client; 380 } 381 } 382 } 383 #endif 384 362 385 /* get the peer's listening port */ 363 386 sub = tr_bencDictFind( &val, "tcp_port" ); -
trunk/libtransmission/peerext.h
r1614 r1650 220 220 { 221 221 benc_val_t val, * sub; 222 int dbgport, dbgpex;222 int dbgport, dbgpex; 223 223 224 224 if( tr_bencLoad( buf, len, &val, NULL ) ) … … 251 251 } 252 252 253 #if 0 /* ugh, we have to deal with encoding if we do this */ 254 /* get peer's client name */ 255 sub = tr_bencDictFind( &val, "v" ); 256 if( NULL != sub && TYPE_STR == sub->type && 257 ( NULL == peer->client || 0 != strcmp( sub->val.s.s, peer->client ) ) ) 258 { 259 client = tr_bencStealStr( sub ); 260 if( NULL != client ) 261 { 262 free( peer->client ); 263 peer->client = client; 264 } 265 } 266 #endif 267 253 268 /* get peer's listening port */ 254 269 sub = tr_bencDictFind( &val, "p" ); -
trunk/libtransmission/peerparse.h
r1600 r1650 585 585 tr_info_t * inf = &tor->info; 586 586 int ii; 587 char * client;588 587 589 588 if( memcmp( &peer->buf[28], inf->hash, SHA_DIGEST_LENGTH ) ) … … 615 614 } 616 615 617 client = tr_clientForId( (uint8_t *) peer->id );618 616 if( PEER_SUPPORTS_EXTENDED_MESSAGES( &peer->buf[20] ) ) 619 617 { … … 621 619 peer->extStatus = EXTENDED_SUPPORTED; 622 620 peer_dbg( "GET handshake, ok (%s) extended messaging supported", 623 client);621 tr_peerClient( peer ) ); 624 622 } 625 623 else if( PEER_SUPPORTS_AZUREUS_PROTOCOL( &peer->buf[20] ) ) … … 629 627 peer->date = tr_date(); 630 628 peer_dbg( "GET handshake, ok (%s) will use azureus protocol", 631 client);629 tr_peerClient( peer ) ); 632 630 } 633 631 else 634 632 { 635 633 peer->status = PEER_STATUS_CONNECTED; 636 peer_dbg( "GET handshake, ok (%s)", client ); 637 } 638 free( client ); 634 peer_dbg( "GET handshake, ok (%s)", tr_peerClient( peer ) ); 635 } 639 636 640 637 return TR_OK; -
trunk/libtransmission/torrent.c
r1636 r1650 498 498 } 499 499 500 peers[i].client = tr_clientForId(tr_peerId(peer)); 501 500 peers[i].client = tr_peerClient( peer ); 502 501 peers[i].isConnected = tr_peerIsConnected( peer ); 503 502 peers[i].from = tr_peerIsFrom( peer ); … … 522 521 } 523 522 524 void tr_torrentPeersFree( tr_peer_stat_t * peers, int peerCount ) 525 { 526 int i; 527 523 void tr_torrentPeersFree( tr_peer_stat_t * peers, int peerCount UNUSED ) 524 { 528 525 if (peers == NULL) 529 526 return; 530 531 for (i = 0; i < peerCount; i++)532 free( peers[i].client );533 527 534 528 free( peers ); -
trunk/libtransmission/transmission.h
r1636 r1650 453 453 { 454 454 char addr[INET_ADDRSTRLEN]; 455 c har *client;455 const char * client; 456 456 457 457 int isConnected;
Note: See TracChangeset
for help on using the changeset viewer.