conncheck: properly select tcp-active discovered candidate
authorFabrice Bellet <fabrice@bellet.info>
Mon, 20 Apr 2020 21:24:21 +0000 (23:24 +0200)
committerOlivier CrĂȘte <olivier.crete@ocrete.ca>
Thu, 7 May 2020 17:46:05 +0000 (17:46 +0000)
Some tcp-active discovered peer-reflexive local candidates may only be
recognised by their local socket, if they have the same address and same
port. It may happen when a nat generates an identical mapping from two
different base local candidates.

agent/conncheck.c

index 01731f9..7ba378b 100644 (file)
@@ -1971,9 +1971,14 @@ local_candidate_and_socket_compatible (NiceAgent *agent,
   g_assert (socket);
   g_assert (lcand);
 
-  if (nice_socket_has_compatible_transport (socket, &transport))
+  if (nice_socket_has_compatible_transport (socket, &transport)) {
     ret = (lcand->transport == transport);
-  else if (socket->type == NICE_SOCKET_TYPE_UDP_TURN)
+    /* tcp-active discovered peer-reflexive local candidate, where
+     * socket is the tcp connect related socket */
+    if (ret && transport == NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE &&
+        nice_address_get_port (&lcand->addr) > 0)
+      ret = (lcand->sockptr == socket);
+  } else if (socket->type == NICE_SOCKET_TYPE_UDP_TURN)
     /* Socket of type udp-turn will match a unique local candidate
      * by its sockptr value. An an udp-turn socket doesn't carry enough
      * information when base socket is udp-turn-over-tcp to disambiguate