2
0
Эх сурвалжийг харах

modules/websockets: Changes WS to be a protocol in its own right instead of a flag on TCP/TLS connections

Peter Dunkley 13 жил өмнө
parent
commit
353ad95af2

+ 10 - 1
modules/websocket/ws_handshake.c

@@ -133,6 +133,12 @@ int ws_handle_handshake(struct sip_msg *msg)
 		return 0;
 	}
 
+	if (con->type != PROTO_TCP && con->type != PROTO_TLS)
+	{
+		LM_ERR("unsupported transport: %d", con->type);
+		return 0;
+	}
+
 	/* Process HTTP headers */
 	while (hdr != NULL)
 	{
@@ -304,7 +310,10 @@ int ws_handle_handshake(struct sip_msg *msg)
 
 	/* Make sure Kamailio core sends future messages on this connection
 	   directly to this module */
-	con->flags |= F_CONN_WS;
+	if (con->type == PROTO_TLS)
+		con->type = con->rcv.proto = PROTO_WSS;
+	else
+		con->type = con->rcv.proto = PROTO_WS;
 
 	return 0;
 }