1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-06-17 17:29:32 +00:00

sip-origin: Always include the transport parameter in sip URLs

This simplifies the code as well as fixes issues with newer sofia
requiring the 'transport=tls' to be present for SIPS.

Closes: #482
This commit is contained in:
Evangelos Ribeiro Tzaras 2023-05-03 10:40:45 +02:00
parent 1cff3a46cb
commit 3069a4af50

View file

@ -953,8 +953,8 @@ setup_nua (CallsSipOrigin *self)
const char *ipv4_bind = "0.0.0.0";
const char *uuid = NULL;
g_autofree char *urn_uuid = NULL;
g_autofree char *sip_url = NULL;
g_autofree char *sips_url = NULL;
g_autofree char *url = NULL;
g_autofree char *protocol_lower = NULL;
g_autofree char *from_str = NULL;
if (!STR_IS_NULL_OR_EMPTY (sip_test_env)) {
@ -969,6 +969,7 @@ setup_nua (CallsSipOrigin *self)
urn_uuid = g_strdup_printf ("urn:uuid:%s", uuid);
self->protocol_prefix = get_protocol_prefix (self->transport_protocol);
protocol_lower = g_ascii_strdown (self->transport_protocol, -1);
self->address = g_strconcat (self->user, "@", self->host, NULL);
from_str = g_strconcat (self->protocol_prefix, ":", self->address, NULL);
@ -978,37 +979,24 @@ setup_nua (CallsSipOrigin *self)
use_sips = check_sips (from_str);
use_ipv6 = check_ipv6 (self->host);
if (self->local_port > 0) {
sip_url = g_strdup_printf ("sip:%s:%d",
use_ipv6 ? ipv6_bind : ipv4_bind,
self->local_port);
sips_url = g_strdup_printf ("sips:%s:%d",
use_ipv6 ? ipv6_bind : ipv4_bind,
self->local_port);
} else {
sip_url = g_strdup_printf ("sip:%s:*",
use_ipv6 ? ipv6_bind : ipv4_bind);
sips_url = g_strdup_printf ("sips:%s:*",
use_ipv6 ? ipv6_bind : ipv4_bind);
}
/** For TLS nua_create() will error if NUTAG_URL includes ";transport=tls"
* In that case NUTAG_SIPS_URL should be used and NUTAG_URL should be as usual
* Since UDP is the default we only need to append the suffix in the TCP case
*/
if (g_ascii_strcasecmp (self->transport_protocol, "TCP") == 0) {
char *temp = sip_url;
sip_url = g_strdup_printf ("%s;transport=%s", temp, self->transport_protocol);
g_free (temp);
}
if (self->local_port > 0)
url = g_strdup_printf ("%s:%s:%d;transport=%s",
self->protocol_prefix,
use_ipv6 ? ipv6_bind : ipv4_bind,
self->local_port,
protocol_lower);
else
url = g_strdup_printf ("%s:%s:*;transport=%s",
self->protocol_prefix,
use_ipv6 ? ipv6_bind : ipv4_bind,
protocol_lower);
nua = nua_create (self->ctx->root,
sip_callback,
self,
NUTAG_USER_AGENT (APP_DATA_NAME),
TAG_IF (!use_sips, NUTAG_URL (sip_url)),
TAG_IF (use_sips, NUTAG_SIPS_URL (sips_url)),
TAG_IF (!use_sips, NUTAG_URL (url)),
TAG_IF (use_sips, NUTAG_SIPS_URL (url)),
SIPTAG_FROM_STR (from_str),
NUTAG_ALLOW ("INVITE, ACK, BYE, CANCEL, OPTIONS, UPDATE"),
NUTAG_SUPPORTED ("replaces, gruu, outbound"),