From 3d31bd65cf5b582b8a9667c0abbf28cd77c5873d Mon Sep 17 00:00:00 2001 From: Honghai Zhang Date: Wed, 10 Aug 2016 10:33:05 -0700 Subject: [PATCH] Do not create incompatible TurnPort if the server address family is known. In the existing code, if the server address and the local IP family does not match, we still create a TurnPort and destroy it later. Instead, we could avoid creating it at the beginning. This does not affect the client behavior except for the port creation. BUG= R=deadbeef@webrtc.org, pthatcher@webrtc.org, zhihuang@webrtc.org Review URL: https://codereview.webrtc.org/2206713004 . Cr-Commit-Position: refs/heads/master@{#13720} --- webrtc/p2p/client/basicportallocator.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/webrtc/p2p/client/basicportallocator.cc b/webrtc/p2p/client/basicportallocator.cc index 658bac3e88..55b1fd8875 100644 --- a/webrtc/p2p/client/basicportallocator.cc +++ b/webrtc/p2p/client/basicportallocator.cc @@ -1296,6 +1296,19 @@ void AllocationSequence::CreateTurnPort(const RelayServerConfig& config) { continue; } + // Do not create a port if the server address family is known and does + // not match the local IP address family. + int server_ip_family = relay_port->address.ipaddr().family(); + int local_ip_family = ip_.family(); + if (server_ip_family != AF_UNSPEC && server_ip_family != local_ip_family) { + LOG(LS_INFO) << "Server and local address families are not compatible. " + << "Server address: " + << relay_port->address.ipaddr().ToString() + << " Local address: " << ip_.ToString(); + continue; + } + + // Shared socket mode must be enabled only for UDP based ports. Hence // don't pass shared socket for ports which will create TCP sockets. // TODO(mallinath) - Enable shared socket mode for TURN ports. Disabled