diff options
author | Robin Gareus <robin@gareus.org> | 2020-02-24 22:05:47 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2020-02-24 22:06:15 +0100 |
commit | 1074c16299b796d372800f8631b2960d58573870 (patch) | |
tree | 38bde26adfcb17292acc52c1fd8728b177bc2547 /libs/surfaces/websockets | |
parent | bd00db9e8bcac8dab3e7eda077a4b50a678fa237 (diff) |
Websockets: error on unhandled callbacks
This prevents unhandled http request from hogging the backend.
Diffstat (limited to 'libs/surfaces/websockets')
-rw-r--r-- | libs/surfaces/websockets/server.cc | 21 |
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; } |