adding nat-map option to mod_event_socket

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13567 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Brian West 2009-06-03 14:25:35 +00:00
parent 71bb1b3efb
commit d59ebd6450
2 changed files with 19 additions and 0 deletions

View File

@ -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"/>

View File

@ -115,6 +115,7 @@ static struct {
char *acl[MAX_ACL];
uint32_t acl_count;
uint32_t id;
int nat_map;
} prefs;
@ -2211,6 +2212,10 @@ static int config(void)
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 @@ static int config(void)
set_pref_pass("ClueCon");
}
if (!prefs.nat_map) {
prefs.nat_map = 0;
}
if (!prefs.port) {
prefs.port = 8021;
}
@ -2276,6 +2285,11 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_event_socket_runtime)
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 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_event_socket_runtime)
}
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);