summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Zabaluev <mikhail.zabaluev@nokia.com>2011-02-14 18:13:28 +0200
committerMikhail Zabaluev <mikhail.zabaluev@nokia.com>2011-02-15 14:43:42 +0200
commit0edb5ebf4391d53214ab44284968e548f74d8faa (patch)
treedc2de41b685a52154a61ab881a6dd40037ae685c
parent13d1557121f2a20eb98b8b2d0786d57f1a35edb2 (diff)
Smarter behavior of connection parameters 'discover-stun' and 'stun-server'
'discover-stun' is no longer ignored if 'stun-server' is set. If 'discover-stun' is set to true, 'stun-server' is now ignored. If 'discover-stun' is not set, 'stun-server' is used if that is set, otherwise 'discover-stun' defaults to true. Fixes: fd.o #34227
-rw-r--r--src/protocol.c22
-rw-r--r--src/sip-connection.c6
2 files changed, 22 insertions, 6 deletions
diff --git a/src/protocol.c b/src/protocol.c
index 44bbd4d..7d89d6c 100644
--- a/src/protocol.c
+++ b/src/protocol.c
@@ -113,13 +113,14 @@ static TpCMParamSpec rakia_params[] = {
{ "keepalive-interval", DBUS_TYPE_UINT32_AS_STRING, G_TYPE_UINT,
TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, GUINT_TO_POINTER(0), PARAM_EASY },
- /* Use SRV DNS lookup to discover STUN server */
+ /* Use SRV DNS lookup to discover STUN server
+ * (defaults to true unless stun-server is set) */
{ "discover-stun", DBUS_TYPE_BOOLEAN_AS_STRING, G_TYPE_BOOLEAN,
- TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT, GUINT_TO_POINTER(TRUE), PARAM_EASY },
+ 0, NULL, PARAM_SET_SEPARATELY },
/* STUN server */
{ "stun-server", DBUS_TYPE_STRING_AS_STRING, G_TYPE_STRING, 0, NULL,
- PARAM_EASY },
+ PARAM_SET_SEPARATELY },
/* STUN port */
{ "stun-port", DBUS_TYPE_UINT16_AS_STRING, G_TYPE_UINT,
@@ -274,6 +275,9 @@ new_connection (TpBaseProtocol *protocol,
const gchar *transport;
const gchar *proxy_host;
guint16 port;
+ gboolean discover_stun;
+ gboolean discover_stun_valid;
+ const gchar *stun_server;
gchar *proxy;
RakiaConnectionKeepaliveMechanism keepalive_mechanism;
@@ -310,6 +314,18 @@ new_connection (TpBaseProtocol *protocol,
"transport", transport,
NULL);
+ discover_stun = tp_asv_get_boolean (params, "discover-stun",
+ &discover_stun_valid);
+ stun_server = tp_asv_get_string (params, "stun-server");
+
+ if (!discover_stun_valid && stun_server == NULL)
+ discover_stun = TRUE;
+
+ g_object_set (conn,
+ "discover-stun", discover_stun,
+ "stun-server", stun_server,
+ NULL);
+
for (i = 0; rakia_params[i].name != NULL; i++)
{
if (rakia_params[i].offset == PARAM_SET_SEPARATELY)
diff --git a/src/sip-connection.c b/src/sip-connection.c
index bf93bc4..81bcce4 100644
--- a/src/sip-connection.c
+++ b/src/sip-connection.c
@@ -1055,10 +1055,10 @@ rakia_connection_start_connecting (TpBaseConnection *base,
rakia_conn_update_nua_keepalive_interval (self);
rakia_conn_update_nua_contact_features (self);
- if (priv->stun_host != NULL)
- rakia_conn_resolv_stun_server (self, priv->stun_host);
- else if (priv->discover_stun)
+ if (priv->discover_stun)
rakia_conn_discover_stun_server (self);
+ else if (priv->stun_host != NULL)
+ rakia_conn_resolv_stun_server (self, priv->stun_host);
DEBUG("initialized a Sofia-SIP NUA at address %p", priv->sofia_nua);