aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Types.hx1
-rw-r--r--src/server/HttpServer.hx6
-rw-r--r--src/server/Main.hx4
3 files changed, 7 insertions, 4 deletions
diff --git a/src/Types.hx b/src/Types.hx
index ae13a6a..c791733 100644
--- a/src/Types.hx
+++ b/src/Types.hx
@@ -17,6 +17,7 @@ typedef Config = {
serverChatHistory:Int,
totalVideoLimit:Int,
userVideoLimit:Int,
+ localAdmins:Bool,
templateUrl:String,
youtubeApiKey:String,
permissions:{
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;
}
diff --git a/src/server/Main.hx b/src/server/Main.hx
index b4fe68e..31ac1f9 100644
--- a/src/server/Main.hx
+++ b/src/server/Main.hx
@@ -87,7 +87,7 @@ class Main {
});
final dir = '$rootDir/res';
- HttpServer.init(dir, '$rootDir/user/res');
+ HttpServer.init(dir, '$rootDir/user/res', config.localAdmins);
Lang.init('$dir/langs');
final server = Http.createServer((req, res) -> {
@@ -238,7 +238,7 @@ class Main {
final id = freeIds.length > 0 ? freeIds.shift() : clients.length;
final name = 'Guest ${id + 1}';
trace('$name connected ($ip)');
- final isAdmin = req.connection.localAddress == ip;
+ final isAdmin = config.localAdmins && req.connection.localAddress == ip;
final client = new Client(ws, req, id, name, 0);
client.isAdmin = isAdmin;
clients.push(client);
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage