[svn-commits] beagles: trunk r373404 - in /trunk: ./ configs/ res/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Sep 24 07:42:25 CDT 2012


Author: beagles
Date: Mon Sep 24 07:42:19 2012
New Revision: 373404

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=373404
Log:
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

Modified:
    trunk/   (props changed)
    trunk/configs/rtp.conf.sample
    trunk/res/res_rtp_asterisk.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.

Modified: trunk/configs/rtp.conf.sample
URL: http://svnview.digium.com/svn/asterisk/trunk/configs/rtp.conf.sample?view=diff&rev=373404&r1=373403&r2=373404
==============================================================================
--- trunk/configs/rtp.conf.sample (original)
+++ trunk/configs/rtp.conf.sample Mon Sep 24 07:42:19 2012
@@ -36,16 +36,22 @@
 ; Whether to enable or disable ICE support. This option is enabled by default.
 ; icesupport=false
 ;
-; Address to use for the STUN server when determining the external IP address and port
-; an RTP session can be reached at. This option is disabled by default.
+; Hostname or address for the STUN server used when determining the external
+; IP address and port an RTP session can be reached at. The port number is
+; optional. If omitted the default value of 3478 will be used. This option is
+; disabled by default.
+;
+; e.g. stundaddr=mystun.server.com:3478
+;
 ; stunaddr=
 ;
-; Address to use for the TURN relay server when creating a TURN relay session. This option
-; is disabled by default.
+; Hostname or address for the TURN server to be used as a relay. The port
+; number is optional. If omitted the default value of 3478 will be used.
+; This option is disabled by default.
+;
+; e.g. turnaddr=myturn.server.com:34780
+;
 ; turnaddr=
-;
-; Port used to contact the TURN relay server on. This option is set to 34780 by default.
-; turnport=34780
 ;
 ; Username used to authenticate with TURN relay server.
 ; turnusername=

Modified: trunk/res/res_rtp_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_rtp_asterisk.c?view=diff&rev=373404&r1=373403&r2=373404
==============================================================================
--- trunk/res/res_rtp_asterisk.c (original)
+++ trunk/res/res_rtp_asterisk.c Mon Sep 24 07:42:19 2012
@@ -4320,8 +4320,22 @@
 	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 @@
 			}
 		}
 		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"))) {




More information about the svn-commits mailing list