1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 01:03:01 +00:00

Store the peers's listening port instead of the peer connections's remote port.

This commit is contained in:
Josh Elsasser 2007-01-28 00:24:41 +00:00
parent 263bf6ff0c
commit f884a9c4d4
3 changed files with 13 additions and 8 deletions

View file

@ -358,8 +358,14 @@ int tr_fdSocketAccept( int b, struct in_addr * addr, in_port_t * port )
if( s > -1 )
{
SocketSetPriority( s, 0 );
if( NULL != addr )
{
*addr = sock.sin_addr;
}
if( NULL != port )
{
*port = sock.sin_port;
}
gFd->normal++;
}
tr_lockUnlock( &gFd->lock );

View file

@ -41,7 +41,7 @@ struct tr_peer_s
tr_torrent_t * tor;
struct in_addr addr;
in_port_t port;
in_port_t port; /* peer's listening port, 0 if not known */
#define PEER_STATUS_IDLE 1 /* Need to connect */
#define PEER_STATUS_CONNECTING 2 /* Trying to send handshake */
@ -617,8 +617,8 @@ int tr_peerGetConnectable( tr_torrent_t * tor, uint8_t ** _buf )
{
peer = tor->peers[i];
/* Skip peers that came from incoming connections */
if( peer->incoming )
/* Skip peers with no known listening port */
if( 0 == peer->port )
continue;
memcpy( &buf[count*6], &peer->addr, 4 );

View file

@ -320,7 +320,6 @@ static void SetPublicPort( tr_shared_t * s, int port )
static void AcceptPeers( tr_shared_t * s )
{
int socket;
in_port_t port;
struct in_addr addr;
for( ;; )
@ -330,12 +329,12 @@ static void AcceptPeers( tr_shared_t * s )
break;
}
socket = tr_netAccept( s->bindSocket, &addr, &port );
socket = tr_netAccept( s->bindSocket, &addr, NULL );
if( socket < 0 )
{
break;
}
s->peers[s->peerCount++] = tr_peerInit( addr, port, socket );
s->peers[s->peerCount++] = tr_peerInit( addr, 0, socket );
}
}