1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-03-09 13:50:00 +00:00

Retrieve peer address as a string via tr_torrentPeers().

This commit is contained in:
Josh Elsasser 2006-08-14 22:42:32 +00:00
parent bb5e80c98d
commit f41a6ade33
4 changed files with 23 additions and 0 deletions

View file

@ -305,6 +305,16 @@ uint8_t * tr_peerId( tr_peer_t * peer )
return & peer->id[0];
}
/***********************************************************************
* tr_peerAddress
***********************************************************************
*
**********************************************************************/
struct in_addr * tr_peerAddress( tr_peer_t * peer )
{
return &peer->addr;
}
/***********************************************************************
* tr_peerHash
***********************************************************************

View file

@ -52,5 +52,6 @@ void tr_peerSetOptimistic ( tr_peer_t *, int );
int tr_peerIsOptimistic ( tr_peer_t * );
void tr_peerBlame ( tr_torrent_t *, tr_peer_t *,
int piece, int success );
struct in_addr * tr_peerAddress ( tr_peer_t * );
#endif

View file

@ -494,11 +494,18 @@ tr_peer_stat_t * tr_torrentPeers( tr_torrent_t * tor, int * peerCount )
if (peers != NULL)
{
tr_peer_t * peer;
struct in_addr * addr;
int i = 0;
for( i = 0; i < tor->peerCount; i++ )
{
peer = tor->peers[i];
addr = tr_peerAddress( peer );
if( NULL != addr )
{
inet_ntop( AF_INET, addr, peers[i].addr,
sizeof( peers[i].addr ) );
}
peers[i].client = tr_clientForId(tr_peerId(peer));
peers[i].isDownloading = tr_peerIsDownloading(peer);
peers[i].isUploading = tr_peerIsUploading(peer);

View file

@ -44,6 +44,10 @@ extern "C" {
# define MAX_PATH_LENGTH 1024
#endif
#ifndef INET_ADDRSTRLEN
#define INET_ADDRSTRLEN 16
#endif
#define TR_DEFAULT_PORT 9090
#define TR_NOERROR 0
@ -321,6 +325,7 @@ struct tr_stat_s
struct tr_peer_stat_s
{
char addr[INET_ADDRSTRLEN];
char * client;
int isDownloading;