From 07d753528109b7ae0a9870a710066e3eead396d4 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Thu, 23 May 2024 14:22:11 +0100 Subject: Add support for non-web WebSocket connections. Closes #2066. --- src/modules/m_websocket.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/modules/m_websocket.cpp') diff --git a/src/modules/m_websocket.cpp b/src/modules/m_websocket.cpp index 40f726b0f..e072aaac5 100644 --- a/src/modules/m_websocket.cpp +++ b/src/modules/m_websocket.cpp @@ -58,6 +58,9 @@ struct WebSocketConfig final // The IP ranges which send trustworthy X-Real-IP or X-Forwarded-For headers. ProxyRanges proxyranges; + // Whether to allow connections from clients that do not send an Origin header. + bool allowmissingorigin; + // Whether to send WebSocket ping messages instead of IRC ping messages. bool nativeping; }; @@ -400,6 +403,11 @@ class WebSocketHook final } } } + else if (config.allowmissingorigin) + { + // This is a non-web WebSocket connection. + allowedorigin = true; + } else { FailHandshake(sock, "HTTP/1.1 400 Bad Request\r\nConnection: close\r\n\r\n", "WebSocket: Received HTTP request that did not send the Origin header"); @@ -662,6 +670,7 @@ public: for (std::string proxyrange; proxyranges.GetToken(proxyrange); ) config.proxyranges.push_back(proxyrange); + config.allowmissingorigin = tag->getBool("allowmissingorigin", true); config.nativeping = tag->getBool("nativeping", true); // Everything is okay; apply the new config. -- cgit v1.3.1-10-gc9f91