From b5fba934838ef3c47b51da29f84b3c6e10fdf76b Mon Sep 17 00:00:00 2001 From: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com> Date: Fri, 10 Nov 2017 13:28:25 -0500 Subject: [PATCH] ice: log warn when no public IPv4 present in DHT msg This is a helper to detect cases where the connection cannot be established due to absence of public addresses. Change-Id: Ibfdc221624f5edc9e8e0b9bcebc35e2b5335770f --- src/ice_transport.cpp | 7 ++++++- src/ice_transport.h | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ice_transport.cpp b/src/ice_transport.cpp index 7adc55d4c8..791b9303a4 100644 --- a/src/ice_transport.cpp +++ b/src/ice_transport.cpp @@ -487,6 +487,9 @@ IceTransport::start(const std::vector<uint8_t>& rem_data) return false; } + if (onlyIPv4Private_) + RING_WARN("[ice:%p] no public IPv4 found, your connection may fail!", this); + return start({rem_ufrag, rem_pwd}, rem_candidates); } @@ -854,8 +857,10 @@ IceTransport::getCandidateFromSDP(const std::string& line, IceCandidate& cand) if (strchr(ipaddr, ':')) af = pj_AF_INET6(); - else + else { af = pj_AF_INET(); + onlyIPv4Private_ &= IpAddr(ipaddr).isPrivate(); + } tmpaddr = pj_str(ipaddr); pj_sockaddr_init(af, &cand.addr, NULL, 0); diff --git a/src/ice_transport.h b/src/ice_transport.h index fbd2b54ffd..990c88d1de 100644 --- a/src/ice_transport.h +++ b/src/ice_transport.h @@ -297,6 +297,8 @@ class IceTransport { std::unique_ptr<upnp::Controller> upnp_; + bool onlyIPv4Private_ {true}; + // IO/Timer events are handled by following thread std::thread thread_; std::atomic_bool threadTerminateFlags_ {false}; -- GitLab