aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2021-09-27 19:41:27 +0300
committerRblSb <msrblsb@gmail.com>2021-09-27 19:41:27 +0300
commitd3c34032ef86163d683ef22906481e0f3196ae79 (patch)
tree67cdffa949819f3104d2298e70b2a40f94d26ffc /src
parentf76c28ea26ab42fbc7f8232e5cc0b41f1e1d99d1 (diff)
Allow proxy ips by default
And improve server output
Diffstat (limited to 'src')
-rw-r--r--src/Types.hx1
-rw-r--r--src/server/Main.hx13
2 files changed, 8 insertions, 6 deletions
diff --git a/src/Types.hx b/src/Types.hx
index 3a3f437..90952e2 100644
--- a/src/Types.hx
+++ b/src/Types.hx
@@ -25,6 +25,7 @@ typedef Config = {
userVideoLimit:Int,
requestLeaderOnPause:Bool,
localAdmins:Bool,
+ allowProxyIps:Bool,
templateUrl:String,
youtubeApiKey:String,
youtubePlaylistLimit:Int,
diff --git a/src/server/Main.hx b/src/server/Main.hx
index cb171ac..b9e9325 100644
--- a/src/server/Main.hx
+++ b/src/server/Main.hx
@@ -299,11 +299,10 @@ class Main {
function clientIp(req:IncomingMessage):String {
// Heroku uses internal proxy, so header cannot be spoofed
- if (isHeroku) {
- var forwarded:String = req.headers["x-forwarded-for"];
- forwarded = forwarded.split(",")[0].trim();
+ if (config.allowProxyIps || isHeroku) {
+ final forwarded:String = req.headers["x-forwarded-for"];
if (forwarded == null || forwarded.length == 0) return req.socket.remoteAddress;
- return forwarded;
+ return forwarded.split(",")[0].trim();
}
return req.socket.remoteAddress;
}
@@ -360,7 +359,7 @@ class Main {
final ip = clientIp(req);
final id = freeIds.length > 0 ? freeIds.shift() : clients.length;
final name = 'Guest ${id + 1}';
- trace('$name connected ($ip)');
+ trace(Date.now().toString(), '$name connected ($ip)');
final isAdmin = config.localAdmins && req.socket.localAddress == ip;
final client = new Client(ws, req, id, name, 0);
client.isAdmin = isAdmin;
@@ -435,7 +434,7 @@ class Main {
case Disconnected:
if (!internal) return;
- trace('Client ${client.name} disconnected');
+ trace(Date.now().toString(), 'Client ${client.name} disconnected');
Utils.sortedPush(freeIds, client.id);
clients.remove(client);
sendClientList();
@@ -522,6 +521,7 @@ class Main {
return;
}
}
+ trace(Date.now().toString(), 'Client ${client.name} logged as $name');
client.name = name;
client.isUser = true;
checkBan(client);
@@ -542,6 +542,7 @@ class Main {
final id = clients.indexOf(client) + 1;
client.name = 'Guest $id';
client.isUser = false;
+ trace(Date.now().toString(), 'Client $oldName logout to ${client.name}');
send(client, {
type: data.type,
logout: {
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage