Module: kamailio
Branch: 5.1
Commit: b433948421f94258c636fcef88601e35360f0102
URL:
https://github.com/kamailio/kamailio/commit/b433948421f94258c636fcef88601e3…
Author: Timmo Verlaan <tverlaan(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2018-01-13T18:25:09+01:00
nathelper: allow port to be specified in force_socket, fixes #1298
(cherry picked from commit 64cf6ee50f569cd398f66ad8d7921acf2e5627bc)
---
Modified: src/modules/nathelper/doc/nathelper_admin.xml
Modified: src/modules/nathelper/nathelper.c
---
Diff:
https://github.com/kamailio/kamailio/commit/b433948421f94258c636fcef88601e3…
Patch:
https://github.com/kamailio/kamailio/commit/b433948421f94258c636fcef88601e3…
---
diff --git a/src/modules/nathelper/doc/nathelper_admin.xml
b/src/modules/nathelper/doc/nathelper_admin.xml
index feb5b5cbe4..513c48400e 100644
--- a/src/modules/nathelper/doc/nathelper_admin.xml
+++ b/src/modules/nathelper/doc/nathelper_admin.xml
@@ -128,8 +128,7 @@
<title><varname>force_socket</varname> (string)</title>
<para>
Socket to be used when sending NAT pings for UDP communication.
- It uses the first socket it finds based on the IP address. If
- no one specified, the OS will choose a socket.
+ If no one specified, the OS will choose a socket.
</para>
<para>
<emphasis>
@@ -140,7 +139,7 @@
<title>Set <varname>force_socket</varname> parameter</title>
<programlisting format="linespecific">
...
-modparam("nathelper", "force_socket", "127.0.0.1")
+modparam("nathelper", "force_socket", "127.0.0.1:5060")
...
</programlisting>
</example>
diff --git a/src/modules/nathelper/nathelper.c b/src/modules/nathelper/nathelper.c
index 440033db1a..5eb7f6a12f 100644
--- a/src/modules/nathelper/nathelper.c
+++ b/src/modules/nathelper/nathelper.c
@@ -417,6 +417,8 @@ static int mod_init(void)
struct in_addr addr;
pv_spec_t avp_spec;
str s;
+ int port, proto;
+ str host;
if(nathelper_rpc_init() < 0) {
LM_ERR("failed to register RPC commands\n");
@@ -442,7 +444,12 @@ static int mod_init(void)
}
if(force_socket_str.s && force_socket_str.len > 0) {
- force_socket = grep_sock_info(&force_socket_str, 0, 0);
+ if(parse_phostport(force_socket_str.s, &host.s, &host.len, &port,
&proto) == 0) {
+ force_socket = grep_sock_info(&host, port, proto);
+ if(force_socket == 0) {
+ LM_ERR("non-local force_socket <%s>\n", force_socket_str.s);
+ }
+ }
}
/* create raw socket? */