Преглед на файлове

modules/websocket: updated example configuration and test scripts

- Added options_rx.xml SIPp script
- kamailio.cfg routes OPTIONS to SIPp
- websocket_test.html now using WSS (WS over TLS)
Peter Dunkley преди 13 години
родител
ревизия
64406b209d
променени са 3 файла, в които са добавени 42 реда и са изтрити 9 реда
  1. 12 4
      modules/websocket/example/kamailio.cfg
  2. 28 0
      modules/websocket/example/options_rx.xml
  3. 2 5
      modules/websocket/example/websocket_test.html

+ 12 - 4
modules/websocket/example/kamailio.cfg

@@ -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");

+ 28 - 0
modules/websocket/example/options_rx.xml

@@ -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>
+

+ 2 - 5
modules/websocket/example/websocket_test.html

@@ -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:[email protected] SIP/2.0\r\nVia: SIP/2.0/WSS abcd1234.invalid;branch=z9hG4bkabcd1234\r\nMax-Forwards: 70\r\nTo: <sip:[email protected]>\r\nFrom: <sip:[email protected]>;tag=abcd1234\r\nCall-ID: abcd1234\r\nCSeq: 1 OPTIONS\r\nContact: <sip:bob@abcd1234;transport=ws>\r\n\r\n");
 }
 
 function onClose(evt)