diff options
| author | 2024-05-23 14:22:11 +0100 | |
|---|---|---|
| committer | 2024-05-23 14:22:45 +0100 | |
| commit | 07d753528109b7ae0a9870a710066e3eead396d4 (patch) | |
| tree | 9d64e55157f3a516e85e0ae66f0ca41f73224f5f /src/modules/m_websocket.cpp | |
| parent | Abbreviate the date even more in the debug logger. (diff) | |
Add support for non-web WebSocket connections.
Closes #2066.
Diffstat (limited to 'src/modules/m_websocket.cpp')
| -rw-r--r-- | src/modules/m_websocket.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
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. |
