Module: sip-router
Branch: pd/websocket
Commit: 242920ec30af3a954f8a193d417c671a29d383b4
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=242920e…
Author: Peter Dunkley <peter.dunkley(a)crocodile-rcs.com>
Committer: Peter Dunkley <peter.dunkley(a)crocodile-rcs.com>
Date: Fri Jun 29 23:05:48 2012 +0100
core: Make sure that responses to requests received on a WebSocket are sent on existing connections
- WebSocket servers cannot create connections to WebSocket clients - so
this setting is essential.
- It does exactly the same thing as using set_reply_no_connect() in
kamailio.cfg - but this way it is always on (as it must be) for
WebSockets.
---
receive.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/receive.c b/receive.c
index 4426b6d..9c53e0e 100644
--- a/receive.c
+++ b/receive.c
@@ -172,9 +172,9 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
/* check for the alias stuff */
#ifdef USE_TCP
if (msg->via1->alias && cfg_get(tcp, tcp_cfg, accept_aliases) &&
- (((rcv_info->proto==PROTO_TCP) && !tcp_disable)
+ (((rcv_info->proto==PROTO_TCP || rcv_info->proto==PROTO_WS) && !tcp_disable)
#ifdef USE_TLS
- || ((rcv_info->proto==PROTO_TLS) && !tls_disable)
+ || ((rcv_info->proto==PROTO_TLS || rcv_info->proto==PROTO_WSS) && !tls_disable)
#endif
)
){
@@ -185,7 +185,12 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
}
}
#endif
-
+
+ /* Force connection reuse for responses if the message arrived on a
+ WebSocket */
+ if (rcv_info->proto==PROTO_WS || rcv_info->proto==PROTO_WSS)
+ msg->rpl_send_flags.f |= SND_F_FORCE_CON_REUSE;
+
/* skip: */
DBG("preparing to run routing scripts...\n");
#ifdef STATS
Module: sip-router
Branch: pd/websocket
Commit: 915894b15d9096388a0136d2d2bdf48ef65b4c4a
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=915894b…
Author: Peter Dunkley <peter.dunkley(a)crocodile-rcs.com>
Committer: Peter Dunkley <peter.dunkley(a)crocodile-rcs.com>
Date: Fri Jun 29 23:03:15 2012 +0100
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.
---
modules_k/nathelper/README | 41 ++++++++++++++-------------
modules_k/nathelper/doc/nathelper_admin.xml | 4 ++
modules_k/nathelper/nathelper.c | 8 +++++
3 files changed, 33 insertions(+), 20 deletions(-)
diff --git a/modules_k/nathelper/README b/modules_k/nathelper/README
index c49aac4..cbf4256 100644
--- a/modules_k/nathelper/README
+++ b/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
- <sr-users(a)lists.sip-router.org> and e-mails regarding development
- versions should be sent to <sr-dev(a)lists.sip-router.org>.
+ E-mails regarding any stable Kamailio release should be sent to
+ <sr-users(a)lists.sip-router.org> and e-mails regarding development
+ versions should be sent to <sr-dev(a)lists.sip-router.org>.
- If you want to keep the mail private, send it to
- <sr-users(a)lists.sip-router.org>.
+ If you want to keep the mail private, send it to
+ <sr-users(a)lists.sip-router.org>.
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.
diff --git a/modules_k/nathelper/doc/nathelper_admin.xml b/modules_k/nathelper/doc/nathelper_admin.xml
index d57757a..8f49d03 100644
--- a/modules_k/nathelper/doc/nathelper_admin.xml
+++ b/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
diff --git a/modules_k/nathelper/nathelper.c b/modules_k/nathelper/nathelper.c
index 4007004..4afae00 100644
--- a/modules_k/nathelper/nathelper.c
+++ b/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;
Module: sip-router
Branch: pd/websocket
Commit: 636a6dabd14e08f2255e52a58353822642deda10
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=636a6da…
Author: Peter Dunkley <peter.dunkley(a)crocodile-rcs.com>
Committer: Peter Dunkley <peter.dunkley(a)crocodile-rcs.com>
Date: Fri Jun 29 23:08:19 2012 +0100
modules/websocket: Make sure that all WebSocket messages are sent on connections that already exist
- This is the same as using set_forward_no_connect() and
set_reply_no_connect() in kamailio.cfg. But this means it will
always happen automatically for WebSocket messages.
- This is important as a WebSocket server cannot create connections -
so we always have to use one that already exists.
---
modules/websocket/ws_frame.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/modules/websocket/ws_frame.c b/modules/websocket/ws_frame.c
index 66c797f..ca66582 100644
--- a/modules/websocket/ws_frame.c
+++ b/modules/websocket/ws_frame.c
@@ -260,6 +260,11 @@ static int encode_and_send_ws_frame(ws_frame_t *frame, conn_close_t conn_close)
from = &local_addr;
}
+ /* Regardless of what has been set before _always_ use existing
+ connections for WebSockets. This is required because a WebSocket
+ server (which Kamailio is) CANNOT create connections. */
+ dst.send_flags.f |= SND_F_FORCE_CON_REUSE;
+
if (tcp_send(&dst, from, send_buf, frame_length) < 0)
{
STATS_TX_DROPS;