diff options
author | zugz (tox) <mbays+tox@sdf.org> | 2018-08-14 18:37:32 +0200 |
---|---|---|
committer | zugz (tox) <mbays+tox@sdf.org> | 2018-08-27 22:27:01 +0200 |
commit | 66ab386d6fb0200d544eb841a05b68fc7151101e (patch) | |
tree | 4d7d21d683ccbf9f1270ea036bb94f0d28c23bce /toxcore/net_crypto.c | |
parent | 0075374f2bb3bb72ef1112471f1aacf12b6b6658 (diff) |
try ipv6 connections even after udp timeout
Also adds a test (auto_reconnect_test) which fails without this change.
Diffstat (limited to 'toxcore/net_crypto.c')
-rw-r--r-- | toxcore/net_crypto.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index 76cd27e7..a64ed970 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c | |||
@@ -634,6 +634,9 @@ static IP_Port return_ip_port_connection(Net_Crypto *c, int crypt_connection_id) | |||
634 | v6 = 1; | 634 | v6 = 1; |
635 | } | 635 | } |
636 | 636 | ||
637 | /* Prefer IP_Ports which haven't timed out to those which have. | ||
638 | * To break ties, prefer ipv4 lan, then ipv6, then non-lan ipv4. | ||
639 | */ | ||
637 | if (v4 && ip_is_lan(conn->ip_portv4.ip)) { | 640 | if (v4 && ip_is_lan(conn->ip_portv4.ip)) { |
638 | return conn->ip_portv4; | 641 | return conn->ip_portv4; |
639 | } | 642 | } |
@@ -642,6 +645,18 @@ static IP_Port return_ip_port_connection(Net_Crypto *c, int crypt_connection_id) | |||
642 | return conn->ip_portv6; | 645 | return conn->ip_portv6; |
643 | } | 646 | } |
644 | 647 | ||
648 | if (v4 && net_family_is_ipv4(conn->ip_portv4.ip.family)) { | ||
649 | return conn->ip_portv4; | ||
650 | } | ||
651 | |||
652 | if (ip_is_lan(conn->ip_portv4.ip)) { | ||
653 | return conn->ip_portv4; | ||
654 | } | ||
655 | |||
656 | if (net_family_is_ipv6(conn->ip_portv6.ip.family)) { | ||
657 | return conn->ip_portv6; | ||
658 | } | ||
659 | |||
645 | if (net_family_is_ipv4(conn->ip_portv4.ip.family)) { | 660 | if (net_family_is_ipv4(conn->ip_portv4.ip.family)) { |
646 | return conn->ip_portv4; | 661 | return conn->ip_portv4; |
647 | } | 662 | } |