From 166ea8b21af61ffbb2e3fdd7063241f1740f7bd3 Mon Sep 17 00:00:00 2001 From: Evangelos Ribeiro Tzaras Date: Sun, 11 Apr 2021 00:22:57 +0200 Subject: [PATCH] sip: origin: Allow using a local port of 0 Using a port of 0 let's the operating system decide to which port to bind to. Additionally refuse to use priviliged ports and print a warning. --- plugins/sip/calls-sip-origin.c | 8 +++++++- plugins/sip/calls-sip-provider.c | 6 ------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/sip/calls-sip-origin.c b/plugins/sip/calls-sip-origin.c index bdbd5ac..afee396 100644 --- a/plugins/sip/calls-sip-origin.c +++ b/plugins/sip/calls-sip-origin.c @@ -867,6 +867,12 @@ calls_sip_origin_set_property (GObject *object, break; case PROP_SIP_LOCAL_PORT: + if (g_value_get_int (value) > 0 && g_value_get_int (value) < 1025) { + g_warning ("Tried setting a priviliged port as the local port to bind to: %d\n" + "Continue using old 'local-port' value: %d (using 0 let's the OS decide)", + g_value_get_int (value), self->local_port); + return; + } self->local_port = g_value_get_int (value); break; @@ -1070,7 +1076,7 @@ calls_sip_origin_class_init (CallsSipOriginClass *klass) g_param_spec_int ("local-port", "Local port", "The local port to which the SIP stack binds to", - 1025, 65535, 5060, + 0, 65535, 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); g_object_class_install_property (object_class, PROP_SIP_LOCAL_PORT, props[PROP_SIP_LOCAL_PORT]); diff --git a/plugins/sip/calls-sip-provider.c b/plugins/sip/calls-sip-provider.c index 0122ac0..4d2ee49 100644 --- a/plugins/sip/calls-sip-provider.c +++ b/plugins/sip/calls-sip-provider.c @@ -149,12 +149,6 @@ calls_sip_provider_load_accounts (CallsSipProvider *self) else port = 5060; } - if (local_port == 0) { - if (g_strcmp0 (protocol, "TLS") == 0) - local_port = 5061; - else - local_port = 5060; - } g_debug ("Adding origin for SIP account %s", groups[i]);