summaryrefslogtreecommitdiff
path: root/libs/surfaces
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2020-02-24 22:05:47 +0100
committerRobin Gareus <robin@gareus.org>2020-02-24 22:06:15 +0100
commit1074c16299b796d372800f8631b2960d58573870 (patch)
tree38bde26adfcb17292acc52c1fd8728b177bc2547 /libs/surfaces
parentbd00db9e8bcac8dab3e7eda077a4b50a678fa237 (diff)
Websockets: error on unhandled callbacks
This prevents unhandled http request from hogging the backend.
Diffstat (limited to 'libs/surfaces')
-rw-r--r--libs/surfaces/websockets/server.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/libs/surfaces/websockets/server.cc b/libs/surfaces/websockets/server.cc
index dc002ff949..88984348c8 100644
--- a/libs/surfaces/websockets/server.cc
+++ b/libs/surfaces/websockets/server.cc
@@ -388,7 +388,28 @@ WebsocketsServer::lws_callback (struct lws* wsi, enum lws_callback_reasons reaso
server->write_client (wsi);
break;
+ case LWS_CALLBACK_FILTER_NETWORK_CONNECTION:
+ case LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION:
+ case LWS_CALLBACK_SERVER_NEW_CLIENT_INSTANTIATED:
+ case LWS_CALLBACK_PROTOCOL_INIT:
+ case LWS_CALLBACK_PROTOCOL_DESTROY:
+ case LWS_CALLBACK_WSI_CREATE:
+ case LWS_CALLBACK_WSI_DESTROY:
+ case LWS_CALLBACK_LOCK_POLL:
+ case LWS_CALLBACK_UNLOCK_POLL:
+ case LWS_CALLBACK_WS_PEER_INITIATED_CLOSE:
+ break;
+
+ /* TODO: handle HTTP connections.
+ * Serve static ctrl-surface pages, JS, CSS etc.
+ */
+
default:
+#ifndef NDEBUG
+ /* see libwebsockets.h lws_callback_reasons */
+ std::cerr << "LWS: unhandled callback " << reason << std::endl;
+#endif
+ return -1;
break;
}