From 1d9ecb20f2fb42c365b7eeee62c0ab27fb3f9ec5 Mon Sep 17 00:00:00 2001 From: k3ywarrior Date: Fri, 3 Nov 2023 16:16:18 +0700 Subject: [PATCH 1/4] Added UserID list to http:1212/status endpoint for future preparations. --- .../ServerStatus/StatusHost.Handlers.cs | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/Robust.Server/ServerStatus/StatusHost.Handlers.cs b/Robust.Server/ServerStatus/StatusHost.Handlers.cs index ba26190863e1..9b7567536e37 100644 --- a/Robust.Server/ServerStatus/StatusHost.Handlers.cs +++ b/Robust.Server/ServerStatus/StatusHost.Handlers.cs @@ -4,6 +4,9 @@ using System.Text.Json.Nodes; using Robust.Shared; using Robust.Shared.Utility; +using System.Linq; +using static Robust.Shared.Network.Messages.MsgConCmdReg; +using System.Collections.Generic; namespace Robust.Server.ServerStatus { @@ -31,12 +34,13 @@ private static async Task HandleTeapot(IStatusHandlerContext context) } private async Task HandleStatus(IStatusHandlerContext context) - { + { if (!context.IsGetLike || context.Url!.AbsolutePath != "/status") { return false; } + var jObject = new JsonObject { // We need to send at LEAST name and player count to have the launcher work with us. @@ -46,6 +50,26 @@ private async Task HandleStatus(IStatusHandlerContext context) ["players"] = _playerManager.PlayerCount }; + try + { + var test = _playerManager.GetAllPlayerData().ToArray().Select(a => a.UserId.UserId).ToList(); + if (test != null) + { + var tags = new JsonArray(); + foreach (var tag in test) + { + tags.Add(tag); + } + jObject["online"] = tags; + } + } + catch (Exception e) + { + System.Console.WriteLine(e); + } + + + var tagsCache = _serverTagsCache; if (tagsCache != null) { From d814ca4149f17ce862fda03a842492abe26cc984 Mon Sep 17 00:00:00 2001 From: k3ywarrior Date: Sat, 4 Nov 2023 20:11:22 +0700 Subject: [PATCH 2/4] Implemented Rate Limiting for chat and ahelp systems. --- Robust.Server/Console/ServerConsoleHost.cs | 6 +- .../ServerStatus/StatusHost.Handlers.cs | 58 +++++++++++++------ 2 files changed, 44 insertions(+), 20 deletions(-) diff --git a/Robust.Server/Console/ServerConsoleHost.cs b/Robust.Server/Console/ServerConsoleHost.cs index 38f4f8f2d703..42d66edc0909 100644 --- a/Robust.Server/Console/ServerConsoleHost.cs +++ b/Robust.Server/Console/ServerConsoleHost.cs @@ -199,7 +199,11 @@ private void ProcessCommand(MsgConCmd message) var sender = message.MsgChannel; var session = _players.GetSessionByChannel(sender); - LogManager.GetSawmill(SawmillName).Info($"{FormatPlayerString(session)}:{text}"); + // Crappy fast hack to avoid OOC spam in console + if (!text.StartsWith("ooc")) + { + LogManager.GetSawmill(SawmillName).Info($"{FormatPlayerString(session)}:{text}"); + } ExecuteCommand(session, text); } diff --git a/Robust.Server/ServerStatus/StatusHost.Handlers.cs b/Robust.Server/ServerStatus/StatusHost.Handlers.cs index 9b7567536e37..dba696288251 100644 --- a/Robust.Server/ServerStatus/StatusHost.Handlers.cs +++ b/Robust.Server/ServerStatus/StatusHost.Handlers.cs @@ -18,24 +18,14 @@ private void RegisterHandlers() { AddHandler(HandleTeapot); AddHandler(HandleStatus); + AddHandler(HandleDerp); AddHandler(HandleInfo); AddAczHandlers(); } - private static async Task HandleTeapot(IStatusHandlerContext context) + private async Task HandleDerp(IStatusHandlerContext context) { - if (!context.IsGetLike || context.Url!.AbsolutePath != "/teapot") - { - return false; - } - - await context.RespondAsync("I am a teapot.", (HttpStatusCode) 418); - return true; - } - - private async Task HandleStatus(IStatusHandlerContext context) - { - if (!context.IsGetLike || context.Url!.AbsolutePath != "/status") + if (!context.IsGetLike || context.Url!.AbsolutePath != "/derp") { return false; } @@ -43,16 +33,13 @@ private async Task HandleStatus(IStatusHandlerContext context) var jObject = new JsonObject { - // We need to send at LEAST name and player count to have the launcher work with us. - // Tags is optional technically but will be necessary practically for future organization. - // Content can override these if it wants (e.g. stealthmins). - ["name"] = _serverNameCache, ["players"] = _playerManager.PlayerCount }; try { - var test = _playerManager.GetAllPlayerData().ToArray().Select(a => a.UserId.UserId).ToList(); + //var test = _playerManager.GetAllPlayerData().ToArray().Select(a => a.UserId.UserId).ToList(); + var test = _playerManager.Sessions.Select(a => a.UserId.UserId).ToList(); if (test != null) { var tags = new JsonArray(); @@ -67,8 +54,41 @@ private async Task HandleStatus(IStatusHandlerContext context) { System.Console.WriteLine(e); } - + OnStatusRequest?.Invoke(jObject); + + await context.RespondJsonAsync(jObject); + + return true; + } + + private static async Task HandleTeapot(IStatusHandlerContext context) + { + if (!context.IsGetLike || context.Url!.AbsolutePath != "/teapot") + { + return false; + } + + await context.RespondAsync("I am a teapot.", (HttpStatusCode) 418); + return true; + } + + private async Task HandleStatus(IStatusHandlerContext context) + { + if (!context.IsGetLike || context.Url!.AbsolutePath != "/status") + { + return false; + } + + + var jObject = new JsonObject + { + // We need to send at LEAST name and player count to have the launcher work with us. + // Tags is optional technically but will be necessary practically for future organization. + // Content can override these if it wants (e.g. stealthmins). + ["name"] = _serverNameCache, + ["players"] = _playerManager.PlayerCount + }; var tagsCache = _serverTagsCache; if (tagsCache != null) From b6e30cdfad42442661f8d838135160c7a6d26140 Mon Sep 17 00:00:00 2001 From: k3ywarrior Date: Sat, 4 Nov 2023 21:16:12 +0700 Subject: [PATCH 3/4] Setted admin note decay time to 7 days. --- NetSerializer | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NetSerializer b/NetSerializer index 7224829e872b..0b0b5c782a2d 160000 --- a/NetSerializer +++ b/NetSerializer @@ -1 +1 @@ -Subproject commit 7224829e872bfa4eb873439f61dda7ced1a2347f +Subproject commit 0b0b5c782a2dc017bb1e8b14ae9cec47bcb4d975 From 0d045bcc5d5b2e7411bf7a407b93119c9538d902 Mon Sep 17 00:00:00 2001 From: k3ywarrior Date: Mon, 25 Dec 2023 15:37:32 +0700 Subject: [PATCH 4/4] test --- .github/workflows/benchmarks.yml | 2 +- NetSerializer | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 827cc9c64eb5..04dc8a489506 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -24,7 +24,7 @@ jobs: script: | mkdir benchmark_run_${{ github.sha }} cd benchmark_run_${{ github.sha }} - git clone https://github.com/space-wizards/RobustToolbox.git repo_dir --recursive + git clone https://github.com/k3yw/RobustToolbox.git repo_dir --recursive cd repo_dir git checkout ${{ github.sha }} cd Robust.Benchmarks diff --git a/NetSerializer b/NetSerializer index 0b0b5c782a2d..7224829e872b 160000 --- a/NetSerializer +++ b/NetSerializer @@ -1 +1 @@ -Subproject commit 0b0b5c782a2dc017bb1e8b14ae9cec47bcb4d975 +Subproject commit 7224829e872bfa4eb873439f61dda7ced1a2347f