Bug 1237299 - addedd missing address family to DNS lookup for proxies. r=bwc, a=sylvestre
authorNils Ohlmeier [:drno] <drno@ohlmeier.org>
Mon, 11 Jan 2016 13:39:11 -0800
changeset 310865 a0ac106e1252f23b553e2eec72b4eca662c43abf
parent 310864 e559a00838e457037d771c88c20ed1eb46e754a3
child 310866 01eeea86dfa8f7df306bcc84b217c173658f4202
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbwc, sylvestre
bugs1237299
milestone45.0a2
Bug 1237299 - addedd missing address family to DNS lookup for proxies. r=bwc, a=sylvestre
media/mtransport/third_party/nICEr/src/net/nr_proxy_tunnel.c
--- a/media/mtransport/third_party/nICEr/src/net/nr_proxy_tunnel.c
+++ b/media/mtransport/third_party/nICEr/src/net/nr_proxy_tunnel.c
@@ -262,17 +262,17 @@ abort:
 }
 
 int nr_socket_proxy_tunnel_connect(void *obj, nr_transport_addr *addr)
 {
   int r, _status;
   int has_addr;
   nr_socket_proxy_tunnel *sock = (nr_socket_proxy_tunnel*)obj;
   nr_proxy_tunnel_config *config = sock->config;
-  nr_transport_addr proxy_addr;
+  nr_transport_addr proxy_addr, local_addr;
   nr_resolver_resource resource;
 
   if ((r=nr_transport_addr_copy(&sock->remote_addr, addr))) {
     ABORT(r);
   }
 
   assert(config->proxy_host);
 
@@ -288,16 +288,32 @@ int nr_socket_proxy_tunnel_connect(void 
   }
 
   if (!has_addr) {
     resource.domain_name=config->proxy_host;
     resource.port=config->proxy_port;
     resource.stun_turn=NR_RESOLVE_PROTOCOL_TURN;
     resource.transport_protocol=IPPROTO_TCP;
 
+    if ((r=nr_socket_getaddr(sock->inner, &local_addr))) {
+      r_log(LOG_GENERIC,LOG_ERR,"nr_socket_proxy_tunnel_connect failed to get local address");
+      ABORT(r);
+    }
+
+    switch(local_addr.ip_version) {
+      case NR_IPV4:
+        resource.address_family=AF_INET;
+        break;
+      case NR_IPV6:
+        resource.address_family=AF_INET6;
+        break;
+      default:
+        ABORT(R_BAD_ARGS);
+    }
+
     r_log(LOG_GENERIC,LOG_DEBUG,"nr_socket_proxy_tunnel_connect: nr_resolver_resolve");
     if ((r=nr_resolver_resolve(config->resolver, &resource,
             nr_socket_proxy_tunnel_resolved_cb, (void *)sock, &sock->resolver_handle))) {
       r_log(LOG_GENERIC,LOG_ERR,"Could not invoke DNS resolver");
       ABORT(r);
     }
 
     ABORT(R_WOULDBLOCK);