Skip to content

Commit

Permalink
ws,server: fix server crash
Browse files Browse the repository at this point in the history
Fix server crash when `metarhia-jstp` is not in the list of the
requested protocols.

PR-URL: #380
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
  • Loading branch information
belochub committed Sep 13, 2018
1 parent b49f2ce commit 9c7aa23
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/ws-internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ const initServer = function(options, httpServer) {
httpServer.wsServer = new WebSocketServer(options);

httpServer.wsServer.on('request', request => {
if (!httpServer.isOriginAllowed(request.origin)) {
if (
!httpServer.isOriginAllowed(request.origin) ||
!request.requestedProtocols.includes(constants.WEBSOCKET_PROTOCOL_NAME)
) {
request.reject();
return;
}
Expand Down

0 comments on commit 9c7aa23

Please sign in to comment.