From ca27f2eb045e89277078e772e4ef3f4844dbcb92 Mon Sep 17 00:00:00 2001 From: Ondrej Zara Date: Mon, 15 Apr 2019 14:20:30 +0200 Subject: [PATCH] request validator --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index e8cf34a..796090b 100644 --- a/index.js +++ b/index.js @@ -63,7 +63,7 @@ exports.logging = function(enabled) { log.enabled = enabled; } -exports.ws2mpd = function(httpServer, originRegExp) { +exports.ws2mpd = function(httpServer, requestValidator) { function ready() { log("ws2mpd attached to a http server", httpServer.address()); } (httpServer.listening ? ready() : httpServer.on("listening", ready)); @@ -73,7 +73,7 @@ exports.ws2mpd = function(httpServer, originRegExp) { }); wsServer.on("request", request => { - if (originRegExp && !request.origin.match(originRegExp)) { + if (requestValidator && !requestValidator(request)) { log("rejecting connection from origin", request.origin); return request.reject(); }