[calls] sip: origin: Bind sockets to NIC with default route



commit a5cfd9eb24425b1151f38e788e9da22bebca3338
Author: Evangelos Ribeiro Tzaras <devrtz fortysixandtwo eu>
Date:   Sun Sep 5 16:26:03 2021 +0200

    sip: origin: Bind sockets to NIC with default route
    
    Otherwise sofia may use the wrong interface resulting in unroutable packets.
    
    Closes #317

 plugins/sip/calls-sip-origin.c | 7 +++++++
 1 file changed, 7 insertions(+)
---
diff --git a/plugins/sip/calls-sip-origin.c b/plugins/sip/calls-sip-origin.c
index bfd6a1cb..ba9d7e17 100644
--- a/plugins/sip/calls-sip-origin.c
+++ b/plugins/sip/calls-sip-origin.c
@@ -770,6 +770,7 @@ sip_callback (nua_event_t   event,
 static nua_t *
 setup_nua (CallsSipOrigin *self)
 {
+  const char *sip_test_env = g_getenv ("CALLS_SIP_TEST");
   nua_t *nua;
   gboolean use_sips = FALSE;
   gboolean use_ipv6 = FALSE; /* TODO make configurable or use DNS to figure out if ipv6 is supported*/
@@ -781,6 +782,12 @@ setup_nua (CallsSipOrigin *self)
   g_autofree char *sips_url = NULL;
   g_autofree char *from_str = NULL;
 
+  if (!sip_test_env || sip_test_env[0] == '\0') {
+    CallsNetworkWatch *nw = calls_network_watch_get_default ();
+    ipv4_bind = calls_network_watch_get_ipv4 (nw);
+    ipv6_bind = calls_network_watch_get_ipv6 (nw);
+  }
+
   uuid = nua_generate_instance_identifier (self->ctx->home);
   urn_uuid = g_strdup_printf ("urn:uuid:%s", uuid);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]