From fc70e56096035ab67f012088682a56efdd877df6 Mon Sep 17 00:00:00 2001 From: cel Date: Sun, 11 Aug 2019 20:19:33 -0700 Subject: Add allowAddresses option --- lib/serve.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib') diff --git a/lib/serve.js b/lib/serve.js index d550e0f..d0a9624 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -92,6 +92,14 @@ Serve.prototype.go = function () { return } } + var allowAddresses = conf.allowAddresses + if (allowAddresses) { + var ip = this.req.socket.remoteAddress + if (allowAddresses.indexOf(ip) === -1) { + this.res.writeHead(401) + return this.res.end('Not authorized') + } + } if (this.req.method === 'POST' || this.req.method === 'PUT') { if (/^multipart\/form-data/.test(this.req.headers['content-type'])) { -- cgit v1.2.3