request validator
This commit is contained in:
parent
8ba532b373
commit
ca27f2eb04
1 changed files with 2 additions and 2 deletions
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…
Reference in a new issue