WebRTC Bug 4865

Bug 4865: even without STUN/TURN, as long as the peer is on the open internet, the connectivity should work. This is actually a regression even for hangouts.

We need to issue the 0.0.0.0 candidate into Port::candidates_ and filter it out later. The reason is that when we create connection, we need a local candidate to match the remote candidate.

The same connection later will be updated with the prflx local candidate once the STUN ping response is received.

BUG=webrtc:4865
R=juberti@webrtc.org

Review URL: https://codereview.webrtc.org/1274013002 .

Cr-Commit-Position: refs/heads/master@{#9708}
diff --git a/webrtc/base/virtualsocketserver.h b/webrtc/base/virtualsocketserver.h
index b96269c..c708bb4 100644
--- a/webrtc/base/virtualsocketserver.h
+++ b/webrtc/base/virtualsocketserver.h
@@ -38,6 +38,11 @@
 
   SocketServer* socketserver() { return server_; }
 
+  // The default route indicates which local address to use when a socket is
+  // bound to the 'any' address, e.g. 0.0.0.0.
+  IPAddress GetDefaultRoute(int family);
+  void SetDefaultRoute(const IPAddress& from_addr);
+
   // Limits the network bandwidth (maximum bytes per second).  Zero means that
   // all sends occur instantly.  Defaults to 0.
   uint32 bandwidth() const { return bandwidth_; }
@@ -224,6 +229,9 @@
   AddressMap* bindings_;
   ConnectionMap* connections_;
 
+  IPAddress default_route_v4_;
+  IPAddress default_route_v6_;
+
   uint32 bandwidth_;
   uint32 network_capacity_;
   uint32 send_buffer_capacity_;
@@ -248,9 +256,6 @@
   SocketAddress GetLocalAddress() const override;
   SocketAddress GetRemoteAddress() const override;
 
-  // Used by server sockets to set the local address without binding.
-  void SetLocalAddress(const SocketAddress& addr);
-
   // Used by TurnPortTest to mimic a case where proxy returns local host address
   // instead of the original one TurnPort was bound against. Please see WebRTC
   // issue 3927 for more detail.
@@ -297,6 +302,9 @@
   int SendUdp(const void* pv, size_t cb, const SocketAddress& addr);
   int SendTcp(const void* pv, size_t cb);
 
+  // Used by server sockets to set the local address without binding.
+  void SetLocalAddress(const SocketAddress& addr);
+
   VirtualSocketServer* server_;
   int family_;
   int type_;