mirror of
https://github.com/TokTok/c-toxcore
synced 2026-10-23 23:52:27 +00:00
Fixed connection issue.
This commit is contained in:
1 file changed
+11
-2
+11
-2
@@ -406,6 +406,8 @@ static int send_packet_to(Net_Crypto *c, int crypt_connection_id, uint8_t *data,
|
||||
if (conn == 0)
|
||||
return -1;
|
||||
|
||||
int direct_send_attempt = 0;
|
||||
|
||||
//TODO: on bad networks, direct connections might not last indefinitely.
|
||||
if (conn->ip_port.ip.family != 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;
|
||||
|
||||
//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)
|
||||
sendpacket(c->dht->net, conn->ip_port, data, length);
|
||||
if (length < 96 || data[0] == NET_PACKET_COOKIE_REQUEST || data[0] == NET_PACKET_CRYPTO_HS) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if (direct_send_attempt) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user