request validator

This commit is contained in:
Ondrej Zara 2019-04-15 14:20:30 +02:00
parent 8ba532b373
commit ca27f2eb04
1 changed files with 2 additions and 2 deletions

View File

@ -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();
}