summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlfred E. Heggestad <alfred.heggestad@gmail.com>2017-01-21 16:49:57 +0100
committerAlfred E. Heggestad <alfred.heggestad@gmail.com>2017-01-21 16:49:57 +0100
commitecf33122333fd7e6f4e70f93cc2c3baf3b22bdf3 (patch)
tree4662a0d4a0097e302996fef8d01b43f3668b4066 /src
parent4937fe4d40e83a2c018e398c693c9f4ab9696675 (diff)
account: add parameters 'stunuser' and 'stunpass'
the STUN username and password can now be configured with explicit parameters, example: ;stunuser=USERNAME;stunpass=PASSWORD;stunserver=stun:server.org Ref. https://github.com/alfredh/baresip/issues/200
Diffstat (limited to 'src')
-rw-r--r--src/account.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/account.c b/src/account.c
index 0e84eef..e6d9ec8 100644
--- a/src/account.c
+++ b/src/account.c
@@ -63,9 +63,18 @@ static int param_u32(uint32_t *v, const struct pl *params, const char *name)
}
+/*
+ * Decode STUN parameters, inspired by RFC 7064
+ *
+ * See RFC 3986:
+ *
+ * Use of the format "user:password" in the userinfo field is
+ * deprecated.
+ *
+ */
static int stunsrv_decode(struct account *acc, const struct sip_addr *aor)
{
- struct pl srv;
+ struct pl srv, tmp;
struct uri uri;
int err;
@@ -91,12 +100,17 @@ static int stunsrv_decode(struct account *acc, const struct sip_addr *aor)
}
err = 0;
- if (pl_isset(&uri.user))
+
+ if (0 == msg_param_exists(&aor->params, "stunuser", &tmp))
+ err |= param_dstr(&acc->stun_user, &aor->params, "stunuser");
+ else if (pl_isset(&uri.user))
err |= pl_strdup(&acc->stun_user, &uri.user);
else
err |= pl_strdup(&acc->stun_user, &aor->uri.user);
- if (pl_isset(&uri.password))
+ if (0 == msg_param_exists(&aor->params, "stunpass", &tmp))
+ err |= param_dstr(&acc->stun_pass, &aor->params, "stunpass");
+ else if (pl_isset(&uri.password))
err |= pl_strdup(&acc->stun_pass, &uri.password);
else
err |= pl_strdup(&acc->stun_pass, &aor->uri.password);