modules/websocket: updated example configuration and test scripts
authorPeter Dunkley <peter.dunkley@crocodile-rcs.com>
Sat, 23 Jun 2012 20:55:34 +0000 (21:55 +0100)
committerPeter Dunkley <peter.dunkley@crocodile-rcs.com>
Sat, 23 Jun 2012 20:55:34 +0000 (21:55 +0100)
- Added options_rx.xml SIPp script
- kamailio.cfg routes OPTIONS to SIPp
- websocket_test.html now using WSS (WS over TLS)

modules/websocket/example/kamailio.cfg
modules/websocket/example/options_rx.xml [new file with mode: 0644]
modules/websocket/example/websocket_test.html

index cac432c..c5bfb88 100644 (file)
@@ -97,6 +97,14 @@ modparam("tls", "ca_list", "CA/calist.pem")
 # - note: this is the same as route { ... }
 request_route {
 
+       if ($rm == "OPTIONS")
+       {
+               force_rport();
+               $du = "sip:192.168.111.2:5080;transport=udp";
+               forward();
+               exit;
+       }
+
        # per request initial checks
        route(REQINIT);
 
@@ -245,14 +253,14 @@ event_route[xhttp:request] {
                exit;
        }
 
-       xlog("L_INFO", "HTTP Request Received\n");
+       xlog("L_DBG", "HTTP Request Received\n");
 
        if ($hdr(Upgrade)=~"websocket"
                        && $hdr(Connection)=~"Upgrade"
                        && $rm=~"GET") {
-               xlog("L_INFO", "WebSocket\n");
-               xlog("L_INFO", " Host: $hdr(Host)\n");
-               xlog("L_INFO", " Origin: $hdr(Origin)\n");
+               xlog("L_DBG", "WebSocket\n");
+               xlog("L_DBG", " Host: $hdr(Host)\n");
+               xlog("L_DBG", " Origin: $hdr(Origin)\n");
 
                if ($hdr(Host) == $null || !is_myself($hdr(Host))) {
                        xlog("L_WARN", "Bad host $hdr(Host)\n");
diff --git a/modules/websocket/example/options_rx.xml b/modules/websocket/example/options_rx.xml
new file mode 100644 (file)
index 0000000..d3160b6
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Basic OPTIONS responder">
+  <recv request="OPTIONS" crlf="true">
+  </recv>
+
+  <send>
+    <![CDATA[
+
+      SIP/2.0 200 OK
+      [last_Via:]
+      [last_From:]
+      [last_To:];tag=[pid]SIPpTag01[call_number]
+      [last_Call-ID:]
+      [last_CSeq:]
+      Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+      Content-Length: 0
+
+    ]]>
+  </send>
+
+  <timewait milliseconds="4000"/>
+  <ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>
+  <CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>
+
+</scenario>
+
index 308b945..a7f9d20 100644 (file)
@@ -5,7 +5,7 @@
 <title>WebSocket Test</title>
 
 <script language="javascript" type="text/javascript">
-var wsUri = "ws://192.168.111.12/";
+var wsUri = "wss://192.168.111.2/";
 var output;
 
 function init()
@@ -26,10 +26,7 @@ function testWebSocket()
 function onOpen(evt)
 {
        writeToScreen("CONNECTED");
-       doSend("WebSocket rocks");
-       doSend("WebSocket rolls");
-       doSend("012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789");
-       websocket.close();
+       doSend("OPTIONS sip:alice@example.com SIP/2.0\r\nVia: SIP/2.0/WSS abcd1234.invalid;branch=z9hG4bkabcd1234\r\nMax-Forwards: 70\r\nTo: <sip:alice@example.com>\r\nFrom: <sip:bob@example.com>;tag=abcd1234\r\nCall-ID: abcd1234\r\nCSeq: 1 OPTIONS\r\nContact: <sip:bob@abcd1234;transport=ws>\r\n\r\n");
 }
 
 function onClose(evt)