Browse Source

request validator

master
Ondrej Zara 3 years ago
parent
commit
ca27f2eb04
  1. 4
      index.js

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

Loading…
Cancel
Save