[Freeswitch-trunk] [commit] r13567 - in freeswitch/trunk: conf/autoload_configs src/mod/event_handlers/mod_event_socket

FreeSWITCH SVN brian at freeswitch.org
Wed Jun 3 07:25:36 PDT 2009


Author: brian
Date: Wed Jun  3 09:25:35 2009
New Revision: 13567

Log:
 adding nat-map option to mod_event_socket 

Modified:
   freeswitch/trunk/conf/autoload_configs/event_socket.conf.xml
   freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c

Modified: freeswitch/trunk/conf/autoload_configs/event_socket.conf.xml
==============================================================================
--- freeswitch/trunk/conf/autoload_configs/event_socket.conf.xml	(original)
+++ freeswitch/trunk/conf/autoload_configs/event_socket.conf.xml	Wed Jun  3 09:25:35 2009
@@ -1,5 +1,6 @@
 <configuration name="event_socket.conf" description="Socket Client">
   <settings>
+    <param name="nat-map" value="false"/>
     <param name="listen-ip" value="127.0.0.1"/>
     <param name="listen-port" value="8021"/>
     <param name="password" value="ClueCon"/>

Modified: freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
==============================================================================
--- freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c	(original)
+++ freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c	Wed Jun  3 09:25:35 2009
@@ -115,6 +115,7 @@
 	char *acl[MAX_ACL];
 	uint32_t acl_count;
 	uint32_t id;
+	int nat_map;
 } prefs;
 
 
@@ -2211,6 +2212,10 @@
 					set_pref_ip(val);
 				} else if (!strcmp(var, "debug")) {
 					globals.debug = atoi(val);
+				} else if (!strcmp(var, "nat-map")) {
+					if (switch_true(val)) {
+						prefs.nat_map = 1;
+					}
 				} else if (!strcmp(var, "listen-port")) {
 					prefs.port = (uint16_t) atoi(val);
 				} else if (!strcmp(var, "password")) {
@@ -2235,6 +2240,10 @@
 		set_pref_pass("ClueCon");
 	}
 
+	if (!prefs.nat_map) {
+		prefs.nat_map = 0;
+	}
+
 	if (!prefs.port) {
 		prefs.port = 8021;
 	}
@@ -2276,6 +2285,11 @@
 		if (rv)
 			goto sock_fail;
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Socket up listening on %s:%u\n", prefs.ip, prefs.port);
+
+		if (prefs.nat_map) {
+			switch_nat_add_mapping(prefs.port, SWITCH_NAT_TCP);
+		}
+
 		break;
 	  sock_fail:
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Socket Error! Could not listen on %s:%u\n", prefs.ip, prefs.port);
@@ -2326,6 +2340,10 @@
 	}
 
 	close_socket(&listen_list.sock);
+	
+	if (prefs.nat_map) {
+		switch_nat_del_mapping(prefs.port, SWITCH_NAT_TCP);
+	}
 
 	if (pool) {
 		switch_core_destroy_memory_pool(&pool);



More information about the Freeswitch-trunk mailing list