From eb97bdd2597dabe32c206d0e3c845154c295b7e8 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sat, 19 Jun 2021 01:01:48 -0700 Subject: [PATCH] Add helpful note to rest rate-limit error The rate limiting error message used the term "tokens," which could be easily misconstrued to refer to REST auth tokens, and not rate limit leaky-bucket tokens. Since we don't expose the internals of the leaky bucket to end-users, this error message is essentially just not good. Without knowledge of a leaky bucket/GCRA, it really makes no sense. Therefore, this changes the message to indicate that the "tokens" are rate-limit tokens. It also adds a hint that there's a config setting that can be changed to raise the limit, which further makes it more understandable, and also provides a reasonable hint as to what setting to change to alleviate this problem immediately. This makes it easier for users to debug and less likely they have to read old docs/wait for help. --- CHANGELOG.md | 1 + TShockAPI/Rest/SecureRest.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d46aa0d4..d2cfbf26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * Removed the old `ConfigFile` class. If you are updating a plugin, you should use `TShock.Config.Settings` instead of the accessor you were using. This is typically a really easy change. For most plugin authors, updating to the new config format is as simple as changing the reference to the old static config to point to the new location. If you were using this for your own configs, you should swap to using a `IConfigFile` (see `TShockAPI.Configuration.ConfigFile`). (@hakusaro, @bartico6) * Added `Main.worldPathName` to `/worldinfo` command. Now, if you need to see what the location on disk for your world file is, you can simply run `/worldinfo` to find out. This is particularly helpful on Linux and macOS, where the world path isn't obvious. (@hakusaro) * Correct rejection message in LandGolfBallInCupHandler to output the proper expected player id. (@drunderscore) +* Clarified the error mesage that the console is presented if a rate-limit is reached over REST to indicate that "tokens" actually refers to rate-limit tokens, and not auth tokens, and added a hint as to what config setting determines this. (@hakusaro, @patsore) ## TShock 4.5.4 * Fixed ridiculous typo in `GetDataHandlers` which caused TShock to read the wrong field in the packet for `usingBiomeTorches`. (@hakusaro, @Arthri) diff --git a/TShockAPI/Rest/SecureRest.cs b/TShockAPI/Rest/SecureRest.cs index b9b50919..fb281ebc 100644 --- a/TShockAPI/Rest/SecureRest.cs +++ b/TShockAPI/Rest/SecureRest.cs @@ -117,7 +117,7 @@ namespace Rests { if (tokens >= TShock.Config.Settings.RESTMaximumRequestsPerInterval) { - TShock.Log.ConsoleError("A REST login from {0} was blocked as it currently has {1} tokens", context.RemoteEndPoint.Address.ToString(), tokens); + TShock.Log.ConsoleError("A REST login from {0} was blocked as it currently has {1} rate-limit tokens and is at the RESTMaximumRequestsPerInterval thresold.", context.RemoteEndPoint.Address.ToString(), tokens); tokenBucket[context.RemoteEndPoint.Address.ToString()] += 1; // Tokens over limit, increment by one and reject request return new RestObject("403") {