@@ -243,6 +243,8 @@ int conn_mux_prepare(conn_registry_t *registry, struct pollfd *pfd, timestamp_t
243
243
}
244
244
245
245
int count = registry -> agents_count ;
246
+ if (registry -> cb_mux_incoming )
247
+ ++ count ;
246
248
mutex_unlock (& registry -> mutex );
247
249
return count ;
248
250
}
@@ -295,6 +297,25 @@ static juice_agent_t *lookup_agent(conn_registry_t *registry, char *buf, size_t
295
297
}
296
298
}
297
299
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
+ }
298
319
} else {
299
320
if (!STUN_IS_RESPONSE (msg .msg_class )) {
300
321
JLOG_INFO ("Got unexpected STUN message from unknown source address" );
@@ -479,14 +500,7 @@ void conn_mux_unlock(juice_agent_t *agent) {
479
500
mutex_unlock (& registry -> mutex );
480
501
}
481
502
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 ) {
490
504
JLOG_VERBOSE ("Interrupting connections thread" );
491
505
492
506
registry_impl_t * registry_impl = registry -> impl ;
@@ -503,6 +517,17 @@ int conn_mux_interrupt(juice_agent_t *agent) {
503
517
return 0 ;
504
518
}
505
519
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
+
506
531
int conn_mux_send (juice_agent_t * agent , const addr_record_t * dst , const char * data , size_t size ,
507
532
int ds ) {
508
533
conn_impl_t * conn_impl = agent -> conn_impl ;
0 commit comments