aboutsummaryrefslogtreecommitdiff
path: root/lib/serve.js
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2019-08-11 20:19:33 -0700
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2019-08-11 20:20:16 -0700
commitfc70e56096035ab67f012088682a56efdd877df6 (patch)
tree4919635f1d6ae567458e7f61616794c27c0835a3 /lib/serve.js
parent1871d17e657e8e9cac4fa1795116d8ed03ad6df0 (diff)
downloadpatchfoo-fc70e56096035ab67f012088682a56efdd877df6.tar.gz
patchfoo-fc70e56096035ab67f012088682a56efdd877df6.zip
Add allowAddresses option
Diffstat (limited to 'lib/serve.js')
-rw-r--r--lib/serve.js8
1 files changed, 8 insertions, 0 deletions
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'])) {