re-add support for servers without auth

This commit is contained in:
Elijah R 2024-08-01 00:26:08 -04:00
parent eb5beb3e56
commit 888a4ef01c
3 changed files with 16 additions and 4 deletions

View file

@ -23,6 +23,7 @@
], ],
"BOT_PREFIX": "!", "BOT_PREFIX": "!",
"ADMIN_TOKEN": "get_your_own_bot_token", "ADMIN_TOKEN": "get_your_own_bot_token",
"ADMIN_PASSWORD": "yourPasswordGoesHere",
"kGeneralLimitBaseSeconds": 6, "kGeneralLimitBaseSeconds": 6,
"kRebootLimitBaseSeconds": 25 "kRebootLimitBaseSeconds": 25
} }

View file

@ -9,7 +9,8 @@ export default interface Config {
hasUsb: boolean; hasUsb: boolean;
}[]; }[];
BOT_PREFIX: string; BOT_PREFIX: string;
ADMIN_TOKEN: string; ADMIN_TOKEN: string | undefined;
ADMIN_PASSWORD: string | undefined;
kGeneralLimitBaseSeconds: number; kGeneralLimitBaseSeconds: number;
kRebootLimitBaseSeconds: number; kRebootLimitBaseSeconds: number;
} }

View file

@ -6,6 +6,11 @@ import Config from "./config.js";
let config: Config = JSON.parse(fs.readFileSync("config.json", "utf-8")); let config: Config = JSON.parse(fs.readFileSync("config.json", "utf-8"));
if (!config.ADMIN_PASSWORD && !config.ADMIN_TOKEN) {
console.error("Either ADMIN_PASSWORD or ADMIN_TOKEN must be defined in config.json");
process.exit(1);
}
const blankflp = Buffer.alloc(1440000); const blankflp = Buffer.alloc(1440000);
if (!fs.existsSync("media/flp/")) if (!fs.existsSync("media/flp/"))
fs.mkdirSync("media/flp/", { recursive: true }); fs.mkdirSync("media/flp/", { recursive: true });
@ -241,7 +246,8 @@ class HelperBot extends CollabVMClient {
// This should disallow unregistered users, // This should disallow unregistered users,
// please don't fuck the rank up to where I can't do this // please don't fuck the rank up to where I can't do this
if (!(user.GetRank() >= 1)) { // hack lol
if (config.ADMIN_TOKEN && user.GetRank() === 0) {
return; return;
} }
} }
@ -616,8 +622,12 @@ class HelperBot extends CollabVMClient {
} }
Log(`[${this._vmId}]`, `Connected to VM`); Log(`[${this._vmId}]`, `Connected to VM`);
// I'm fucking lazy if (config.ADMIN_PASSWORD) {
this.SendGuacamoleMessage("admin", "2", config.ADMIN_PASSWORD);
} else if (config.ADMIN_TOKEN) {
this.SendGuacamoleMessage("login", config.ADMIN_TOKEN); this.SendGuacamoleMessage("login", config.ADMIN_TOKEN);
}
this.CreateRateLimits(); this.CreateRateLimits();
} }