From 89c44493883a070a944c0295a445eef61116bcba Mon Sep 17 00:00:00 2001 From: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com> Date: Thu, 15 Jun 2017 13:56:17 -0400 Subject: [PATCH] dht/ice: swap IPv4 vs IPv6 dht address priority Use IPv4 over IPv6 if both available from DHT. IPv6 are less NAT'ed so using host addresses is enought to establish connection over IPv6. But it's not the case for IPv4 and must be given in priority if available over IPv6 addresses. Change-Id: Ia7243f415ebaf81208e175b6f5e704263b7594fd --- src/ringdht/ringaccount.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/ringdht/ringaccount.cpp b/src/ringdht/ringaccount.cpp index a8fd85bb95..91146e9ae3 100644 --- a/src/ringdht/ringaccount.cpp +++ b/src/ringdht/ringaccount.cpp @@ -3380,16 +3380,15 @@ RingAccount::registerDhtAddress(IceTransport& ice) // We need a public address in case of NAT'ed network // Trying to use one discovered by DHT service - // IPv4 - const auto& addr4 = dht_.getPublicAddress(AF_INET); - if (addr4.size()) - setPublishedAddress(reg_addr(ice, addr4[0].first)); - - // IPv6 (must be put after IPv4 as SDP support only one address, we priorize IPv6) + // IPv6 (sdp support only one IP, put IPv6 before IPv4 as this last has the priority over IPv6 less NAT'able) const auto& addr6 = dht_.getPublicAddress(AF_INET6); if (addr6.size()) setPublishedAddress(reg_addr(ice, addr6[0].first)); + // IPv4 + const auto& addr4 = dht_.getPublicAddress(AF_INET); + if (addr4.size()) + setPublishedAddress(reg_addr(ice, addr4[0].first)); } else { reg_addr(ice, ip); } -- GitLab