aboutsummaryrefslogtreecommitdiffstats
path: root/src/server/HttpServer.hx
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2020-05-14 01:14:10 +0300
committerRblSb <msrblsb@gmail.com>2020-05-14 01:14:10 +0300
commit9168f9d5a8a6333e45309fdeabb2f71a368a5fce (patch)
treec36664e9bd9eda5e3208b17a3ee7c5f6bddd4851 /src/server/HttpServer.hx
parent2ac659cb17ada55286bed44913cb8479ed1f9288 (diff)
Option to disable unregistered local admins
Diffstat (limited to 'src/server/HttpServer.hx')
-rw-r--r--src/server/HttpServer.hx6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/server/HttpServer.hx b/src/server/HttpServer.hx
index 38cfcfe..aeabe2c 100644
--- a/src/server/HttpServer.hx
+++ b/src/server/HttpServer.hx
@@ -38,12 +38,14 @@ class HttpServer {
static var customDir:String;
static var hasCustomRes = false;
static var allowedLocalFiles:Map<String, Bool> = [];
+ static var allowLocalRequests = false;
- public static function init(dir:String, ?customDir:String):Void {
+ public static function init(dir:String, ?customDir:String, allowLocalRequests:Bool):Void {
HttpServer.dir = dir;
if (customDir == null) return;
HttpServer.customDir = customDir;
hasCustomRes = FileSystem.exists(customDir);
+ HttpServer.allowLocalRequests = allowLocalRequests;
}
public static function serveFiles(req:IncomingMessage, res:ServerResponse):Void {
@@ -51,7 +53,7 @@ class HttpServer {
if (url == "/") url = "/index.html";
var filePath = dir + url;
- if (req.connection.remoteAddress == req.connection.localAddress
+ if (allowLocalRequests && req.connection.remoteAddress == req.connection.localAddress
|| allowedLocalFiles[url]) {
if (serveLocalFile(res, url)) return;
}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage