summaryrefslogtreecommitdiff
path: root/res
diff options
context:
space:
mode:
authorBrent Eagles <beagles@digium.com>2012-09-24 12:42:19 +0000
committerBrent Eagles <beagles@digium.com>2012-09-24 12:42:19 +0000
commitf787f4219a26e5ab7ad93ffa1198e96dfd26fee6 (patch)
treec1bdf422928977d93aff924ddfe1632590bf3659 /res
parentfd98835f1fb45d2b745bd273a590cf488b4c11dd (diff)
res_rtp_asterisk: Make TURN and STUN server configurations consistent.
This patch removes the turnport configuration property and changes the turnaddr property to be a combined host[:port] configuration string. The patch also modifies the documentation in the example configuration to reflect the property changes and adds some additional text indicating how the STUN port is configured. (closes issue ASTERISK-20344) Reported by: beagles Tested by: beagles Review: https://reviewboard.asterisk.org/r/2111/ ........ Merged revisions 373403 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@373404 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res')
-rw-r--r--res/res_rtp_asterisk.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c
index 958d5831c..25fd3d523 100644
--- a/res/res_rtp_asterisk.c
+++ b/res/res_rtp_asterisk.c
@@ -4320,8 +4320,22 @@ static int rtp_reload(int reload)
dtmftimeout = DEFAULT_DTMF_TIMEOUT;
strictrtp = DEFAULT_STRICT_RTP;
learning_min_sequential = DEFAULT_LEARNING_MIN_SEQUENTIAL;
+
+ /** This resource is not "reloaded" so much as unloaded and loaded again.
+ * In the case of the TURN related variables, the memory referenced by a
+ * previously loaded instance *should* have been released when the
+ * corresponding pool was destroyed. If at some point in the future this
+ * resource were to support ACTUAL live reconfiguration and did NOT release
+ * the pool this will cause a small memory leak.
+ */
+
icesupport = DEFAULT_ICESUPPORT;
turnport = DEFAULT_TURN_PORT;
+ memset(&stunaddr, 0, sizeof(stunaddr));
+ turnaddr = pj_str(NULL);
+ turnusername = pj_str(NULL);
+ turnpassword = pj_str(NULL);
+
if (cfg) {
if ((s = ast_variable_retrieve(cfg, "general", "rtpstart"))) {
rtpstart = atoi(s);
@@ -4381,11 +4395,15 @@ static int rtp_reload(int reload)
}
}
if ((s = ast_variable_retrieve(cfg, "general", "turnaddr"))) {
- pj_strdup2(pool, &turnaddr, s);
- }
- if ((s = ast_variable_retrieve(cfg, "general", "turnport"))) {
- if (!(turnport = atoi(s))) {
- turnport = DEFAULT_TURN_PORT;
+ struct sockaddr_in addr;
+ addr.sin_port = htons(DEFAULT_TURN_PORT);
+ if (ast_parse_arg(s, PARSE_INADDR, &addr)) {
+ ast_log(LOG_WARNING, "Invalid TURN server address: %s\n", s);
+ } else {
+ pj_strdup2(pool, &turnaddr, ast_inet_ntoa(addr.sin_addr));
+ /* ntohs() is not a bug here. The port number is used in host byte order with
+ * a pjnat API. */
+ turnport = ntohs(addr.sin_port);
}
}
if ((s = ast_variable_retrieve(cfg, "general", "turnusername"))) {