conncheck: another rare case of local tcp active candidate matching
authorFabrice Bellet <fabrice@bellet.info>
Tue, 5 May 2020 15:09:47 +0000 (17:09 +0200)
committerOlivier CrĂȘte <olivier.crete@ocrete.ca>
Thu, 7 May 2020 17:46:05 +0000 (17:46 +0000)
An inbound stun request may come on a tcp pair, whose tcp-active socket
has just been created and connected (the local candidate port is zero),
but has not caused the creation of a discovered peer-reflexive local
candidate (with a non-zero port). This inbound request is stored in an
early icheck structure to be replayed later. When being processed after
remote creds have been received, we have to find which local candidate
it belongs to, by matching with the address only, without the port.

agent/conncheck.c

index 21a739a..234a879 100644 (file)
@@ -2064,6 +2064,24 @@ conn_check_remote_candidates_set(NiceAgent *agent, NiceStream *stream,
       }
     }
 
+    if (lcand == NULL) {
+      for (j = component->local_candidates; j; j = j->next) {
+        NiceCandidate *cand = j->data;
+        NiceAddress *addr = &cand->base_addr;
+
+        /* tcp-active (not peer-reflexive discovered) local candidate, where
+         * socket is the tcp connect related socket */
+        if (nice_address_equal_no_port (&icheck->local_socket->addr, addr) &&
+            nice_address_get_port (&cand->addr) == 0 &&
+            cand->transport == NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE &&
+            local_candidate_and_socket_compatible (agent, cand,
+            icheck->local_socket)) {
+          lcand = cand;
+          break;
+        }
+      }
+    }
+
     g_assert (lcand != NULL);
 
     for (j = component->remote_candidates; j; j = j->next) {