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:
parent
263bf6ff0c
commit
f884a9c4d4
3 changed files with 13 additions and 8 deletions
|
@ -358,8 +358,14 @@ int tr_fdSocketAccept( int b, struct in_addr * addr, in_port_t * port )
|
||||||
if( s > -1 )
|
if( s > -1 )
|
||||||
{
|
{
|
||||||
SocketSetPriority( s, 0 );
|
SocketSetPriority( s, 0 );
|
||||||
*addr = sock.sin_addr;
|
if( NULL != addr )
|
||||||
*port = sock.sin_port;
|
{
|
||||||
|
*addr = sock.sin_addr;
|
||||||
|
}
|
||||||
|
if( NULL != port )
|
||||||
|
{
|
||||||
|
*port = sock.sin_port;
|
||||||
|
}
|
||||||
gFd->normal++;
|
gFd->normal++;
|
||||||
}
|
}
|
||||||
tr_lockUnlock( &gFd->lock );
|
tr_lockUnlock( &gFd->lock );
|
||||||
|
|
|
@ -41,7 +41,7 @@ struct tr_peer_s
|
||||||
tr_torrent_t * tor;
|
tr_torrent_t * tor;
|
||||||
|
|
||||||
struct in_addr addr;
|
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_IDLE 1 /* Need to connect */
|
||||||
#define PEER_STATUS_CONNECTING 2 /* Trying to send handshake */
|
#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];
|
peer = tor->peers[i];
|
||||||
|
|
||||||
/* Skip peers that came from incoming connections */
|
/* Skip peers with no known listening port */
|
||||||
if( peer->incoming )
|
if( 0 == peer->port )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
memcpy( &buf[count*6], &peer->addr, 4 );
|
memcpy( &buf[count*6], &peer->addr, 4 );
|
||||||
|
|
|
@ -320,7 +320,6 @@ static void SetPublicPort( tr_shared_t * s, int port )
|
||||||
static void AcceptPeers( tr_shared_t * s )
|
static void AcceptPeers( tr_shared_t * s )
|
||||||
{
|
{
|
||||||
int socket;
|
int socket;
|
||||||
in_port_t port;
|
|
||||||
struct in_addr addr;
|
struct in_addr addr;
|
||||||
|
|
||||||
for( ;; )
|
for( ;; )
|
||||||
|
@ -330,12 +329,12 @@ static void AcceptPeers( tr_shared_t * s )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
socket = tr_netAccept( s->bindSocket, &addr, &port );
|
socket = tr_netAccept( s->bindSocket, &addr, NULL );
|
||||||
if( socket < 0 )
|
if( socket < 0 )
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
s->peers[s->peerCount++] = tr_peerInit( addr, port, socket );
|
s->peers[s->peerCount++] = tr_peerInit( addr, 0, socket );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue