ソースを参照

modules_k/nathelper: Added nat_uac_test() check for WebSockets

- At the moment (and until Kamailio and _all_ WebSocket clients support
  outbound) we want to treat WebSocket UAs as behind NATs (even when they
  are not).
- This is so that the aliasing (which is good for TCP/TLS connection reuse
  as well as NAT traversal) can be used to make sure messages to WebSocket
  UAs are routed correctly.
Peter Dunkley 13 年 前
コミット
915894b15d

+ 21 - 20
modules_k/nathelper/README

@@ -472,6 +472,7 @@ fix_nated_register();
      * 16 - test if the source port is different from the port in Via
      * 32 - test if the source IP address of signaling is a RFC1918
        address
+     * 64 - test if the source connection of signaling is a WebSocket
 
    All flags can be bitwise combined, the test returns true if any of the
    tests identified a NAT.
@@ -593,38 +594,38 @@ Chapter 2. Frequently Asked Questions
 
    2.1.
 
-       What happend with “rtpproxy_disable” parameter?
+   What happend with “rtpproxy_disable” parameter?
 
-       It was removed as it became obsolete - now “rtpproxy_sock” can take
-       empty value to disable the rtpproxy functionality.
+   It was removed as it became obsolete - now “rtpproxy_sock” can take
+   empty value to disable the rtpproxy functionality.
 
    2.2.
 
-       Where can I find more about Kamailio?
+   Where can I find more about Kamailio?
 
-       Take a look at http://www.kamailio.org/.
+   Take a look at http://www.kamailio.org/.
 
    2.3.
 
-       Where can I post a question about this module?
+   Where can I post a question about this module?
 
-       First at all check if your question was already answered on one of our
-       mailing lists:
-         * User Mailing List -
-           http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
-         * Developer Mailing List -
-           http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
+   First at all check if your question was already answered on one of our
+   mailing lists:
+     * User Mailing List -
+       http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
+     * Developer Mailing List -
+       http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
 
-       E-mails regarding any stable Kamailio release should be sent to
-       <[email protected]> and e-mails regarding development
-       versions should be sent to <[email protected]>.
+   E-mails regarding any stable Kamailio release should be sent to
+   <[email protected]> and e-mails regarding development
+   versions should be sent to <[email protected]>.
 
-       If you want to keep the mail private, send it to
-       <[email protected]>.
+   If you want to keep the mail private, send it to
+   <[email protected]>.
 
    2.4.
 
-       How can I report a bug?
+   How can I report a bug?
 
-       Please follow the guidelines provided at:
-       http://sip-router.org/tracker.
+   Please follow the guidelines provided at:
+   http://sip-router.org/tracker.

+ 4 - 0
modules_k/nathelper/doc/nathelper_admin.xml

@@ -540,6 +540,10 @@ fix_nated_register();
 			<emphasis>32</emphasis> -  test if the source IP address of
 			signaling is a RFC1918 address
 			</para></listitem>
+			<listitem><para>
+			<emphasis>64</emphasis> -  test if the source connection of
+			signaling is a WebSocket
+			</para></listitem>
 			</itemizedlist>
 		<para>
 		All flags can be bitwise combined, the test returns true if any of 

+ 8 - 0
modules_k/nathelper/nathelper.c

@@ -241,6 +241,7 @@ MODULE_VERSION
 #define	NAT_UAC_TEST_S_1918	0x08
 #define	NAT_UAC_TEST_RPORT	0x10
 #define	NAT_UAC_TEST_O_1918	0x20
+#define NAT_UAC_TEST_WS		0x40
 
 
 #define DEFAULT_RTPP_SET_ID		0
@@ -1279,6 +1280,13 @@ nat_uac_test_f(struct sip_msg* msg, char* str1, char* str2)
 	if ((tests & NAT_UAC_TEST_O_1918) && is1918addr_ip(&msg->rcv.src_ip))
 		return 1;
 
+	/*
+ 	 * tests prototype to check whether the message arrived on a WebSocket
+ 	 */
+	if ((tests & NAT_UAC_TEST_WS)
+		&& (msg->rcv.proto == PROTO_WS || msg->rcv.proto == PROTO_WSS))
+		return 1;
+
 	/* no test succeeded */
 	return -1;