@@ -243,6 +243,8 @@ int conn_mux_prepare(conn_registry_t *registry, struct pollfd *pfd, timestamp_t
243243	}
244244
245245	int  count  =  registry -> agents_count ;
246+ 	if  (registry -> cb_mux_incoming )
247+ 		++ count ;
246248	mutex_unlock (& registry -> mutex );
247249	return  count ;
248250}
@@ -295,6 +297,25 @@ static juice_agent_t *lookup_agent(conn_registry_t *registry, char *buf, size_t
295297			}
296298		}
297299
300+ 		if  (registry -> cb_mux_incoming ) {
301+ 			JLOG_DEBUG ("Found STUN request with unknown ICE ufrag" );
302+ 			char  host [ADDR_MAX_NUMERICHOST_LEN ];
303+ 			if  (getnameinfo ((const  struct  sockaddr  * )& src -> addr , src -> len , host , ADDR_MAX_NUMERICHOST_LEN , NULL , 0 , NI_NUMERICHOST )) {
304+ 				JLOG_ERROR ("getnameinfo failed, errno=%d" , sockerrno );
305+ 				return  NULL ;
306+ 			}
307+ 
308+ 			juice_mux_binding_request_t  incoming_info ;
309+ 
310+ 			incoming_info .local_ufrag  =  local_ufrag ;
311+ 			incoming_info .remote_ufrag  =  separator  +  1 ;
312+ 			incoming_info .address  =  host ;
313+ 			incoming_info .port  =  addr_get_port ((struct  sockaddr  * )src );
314+ 
315+ 			registry -> cb_mux_incoming (& incoming_info , registry -> mux_incoming_user_ptr );
316+ 
317+ 			return  NULL ;
318+ 		}
298319	} else  {
299320		if  (!STUN_IS_RESPONSE (msg .msg_class )) {
300321			JLOG_INFO ("Got unexpected STUN message from unknown source address" );
@@ -479,14 +500,7 @@ void conn_mux_unlock(juice_agent_t *agent) {
479500	mutex_unlock (& registry -> mutex );
480501}
481502
482- int  conn_mux_interrupt (juice_agent_t  * agent ) {
483- 	conn_impl_t  * conn_impl  =  agent -> conn_impl ;
484- 	conn_registry_t  * registry  =  conn_impl -> registry ;
485- 
486- 	mutex_lock (& registry -> mutex );
487- 	conn_impl -> next_timestamp  =  current_timestamp ();
488- 	mutex_unlock (& registry -> mutex );
489- 
503+ int  conn_mux_interrupt_registry (conn_registry_t  * registry ) {
490504	JLOG_VERBOSE ("Interrupting connections thread" );
491505
492506	registry_impl_t  * registry_impl  =  registry -> impl ;
@@ -503,6 +517,17 @@ int conn_mux_interrupt(juice_agent_t *agent) {
503517	return  0 ;
504518}
505519
520+ int  conn_mux_interrupt (juice_agent_t  * agent ) {
521+ 	conn_impl_t  * conn_impl  =  agent -> conn_impl ;
522+ 	conn_registry_t  * registry  =  conn_impl -> registry ;
523+ 
524+ 	mutex_lock (& registry -> mutex );
525+ 	conn_impl -> next_timestamp  =  current_timestamp ();
526+ 	mutex_unlock (& registry -> mutex );
527+ 
528+ 	return  conn_mux_interrupt_registry (registry );
529+ }
530+ 
506531int  conn_mux_send (juice_agent_t  * agent , const  addr_record_t  * dst , const  char  * data , size_t  size ,
507532                  int  ds ) {
508533	conn_impl_t  * conn_impl  =  agent -> conn_impl ;
0 commit comments