From 9aa2e5ccc874de8c3ce6cf332dc53b24a5d9c3df Mon Sep 17 00:00:00 2001 From: catvayor Date: Sun, 8 Sep 2024 22:04:05 +0200 Subject: [PATCH] obfuscate ids --- machines/kat-traque/default.nix | 55 +++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/machines/kat-traque/default.nix b/machines/kat-traque/default.nix index 086773b..12206b9 100644 --- a/machines/kat-traque/default.nix +++ b/machines/kat-traque/default.nix @@ -150,26 +150,43 @@ in }; systemd.services = { traque = { - preStart = '' - cat < /var/lib/traque/Rocket.toml - [release] - port = 8080 - ident = "Traque backend" - template_dir = "${traque-pkg}/share/traque-templates" + path = [ pkgs.outils ]; + preStart = + let + token-file = "/var/lib/traque/token"; + NPCs = [ + "PNJ 0" + "PNJ 1" + ]; + Players = [ + "Équipe 00" + "Équipe 01" + ]; + id-gen = name: ''sha1 <<< "$(cat ${token-file})${name}" | cut -c 1-10''; + in + '' + cat < /var/lib/traque/Rocket.toml + [release] + port = 8080 + ident = "Traque backend" + template_dir = "${traque-pkg}/share/traque-templates" - blurred_move = [0.0005, 0.0005] - bonus_timeout = 5000 - event_timeout = 100 - admin_token = "root" - serve_static = false - teams = [ - { id = "team00", name = "Équipe 00", vieux = false}, - { id = "team01", name = "Équipe 01", vieux = false}, - { id = "npc0", name = "PNJ 0", vieux = true}, - { id = "npc1", name = "PNJ 1", vieux = true}, - ] - EOF - ''; + blurred_move = [0.0005, 0.0005] + bonus_timeout = 120000 + event_timeout = 100 + fairness_timeout = 30000 + admin_token = "$(cat ${token-file})" + serve_static = false + teams = [ + ${ + lib.concatStringsSep ",\n " ( + map (npc: ''{ id = "$(${id-gen npc})", name = "${npc}", vieux = true }'') NPCs + ++ map (player: ''{ id = "$(${id-gen player})", name = "${player}", vieux = false}'') Players + ) + } + ] + EOF + ''; serviceConfig = { WorkingDirectory = "/var/lib/traque"; ExecStart = "${traque-pkg}/bin/traque";