mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Fixed connection issue.
This commit is contained in:
parent
e87929e869
commit
d573271f03
|
@ -406,6 +406,8 @@ static int send_packet_to(Net_Crypto *c, int crypt_connection_id, uint8_t *data,
|
||||||
if (conn == 0)
|
if (conn == 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
int direct_send_attempt = 0;
|
||||||
|
|
||||||
//TODO: on bad networks, direct connections might not last indefinitely.
|
//TODO: on bad networks, direct connections might not last indefinitely.
|
||||||
if (conn->ip_port.ip.family != 0) {
|
if (conn->ip_port.ip.family != 0) {
|
||||||
uint8_t direct_connected = 0;
|
uint8_t direct_connected = 0;
|
||||||
|
@ -415,8 +417,10 @@ static int send_packet_to(Net_Crypto *c, int crypt_connection_id, uint8_t *data,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
//TODO: a better way of sending packets directly to confirm the others ip.
|
//TODO: a better way of sending packets directly to confirm the others ip.
|
||||||
if (length < 96 || data[0] == NET_PACKET_COOKIE_REQUEST || data[0] == NET_PACKET_CRYPTO_HS)
|
if (length < 96 || data[0] == NET_PACKET_COOKIE_REQUEST || data[0] == NET_PACKET_CRYPTO_HS) {
|
||||||
sendpacket(c->dht->net, conn->ip_port, data, length);
|
if ((uint32_t)sendpacket(c->dht->net, conn->ip_port, data, length) == length)
|
||||||
|
direct_send_attempt = 1;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -436,6 +440,11 @@ static int send_packet_to(Net_Crypto *c, int crypt_connection_id, uint8_t *data,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (direct_send_attempt) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user