From 36904b673f819f4a7b26727031cdc963f9901c78 Mon Sep 17 00:00:00 2001 From: White Date: Sat, 31 Dec 2016 11:30:32 +1030 Subject: [PATCH 1/4] Submodule update --- TerrariaServerAPI | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TerrariaServerAPI b/TerrariaServerAPI index 302124e1..ecb3b742 160000 --- a/TerrariaServerAPI +++ b/TerrariaServerAPI @@ -1 +1 @@ -Subproject commit 302124e1bcf6a6661d518b84f630384a90dbcbcb +Subproject commit ecb3b742b795fb489f9fb6f8ee1c17667f64f85a From 4f7a15f9bf9def857ef9b0ce8c8b46e13fe68af3 Mon Sep 17 00:00:00 2001 From: White Date: Sat, 31 Dec 2016 11:33:48 +1030 Subject: [PATCH 2/4] Ensures Netplay.ServerPassword is always empty. This prevents an issue in which packets are sent in an unexpected order resulting in clients being unable to connect when a CLI-defined password is used. A CLI-defined password will now override any TShock config-defined password. --- TShockAPI/TShock.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index fcd30a65..1efab2a3 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -822,6 +822,7 @@ namespace TShockAPI /// AuthToken - The auth token used by the /auth system to grant temporary superadmin access to new admins. public static int AuthToken = -1; + private string _cliPassword = null; /// OnPostInit - Fired when the server loads a map, to perform world specific operations. /// args - The EventArgs object. @@ -829,6 +830,16 @@ namespace TShockAPI { SetConsoleTitle(false); + //This is to prevent a bug where a CLI-defined password causes packets to be + //sent in an unexpected order, resulting in clients being unable to connect + if (!string.IsNullOrEmpty(Netplay.ServerPassword)) + { + //CLI defined password overrides a config password + _cliPassword = Netplay.ServerPassword; + Netplay.ServerPassword = ""; + Config.ServerPassword = _cliPassword; + } + // Disable the auth system if "auth.lck" is present or a superadmin exists if (File.Exists(Path.Combine(SavePath, "auth.lck")) || Users.GetUsers().Exists(u => u.Group == new SuperAdminGroup().Name)) { @@ -2172,7 +2183,14 @@ namespace TShockAPI if (file.MaxSlots > 235) file.MaxSlots = 235; Main.maxNetPlayers = file.MaxSlots + 20; + Netplay.ServerPassword = ""; + if (!string.IsNullOrEmpty(_cliPassword)) + { + //This prevents a config reload from removing/updating a CLI-defined password + file.ServerPassword = _cliPassword; + } + Netplay.spamCheck = false; } } From 24da3890505f82f0e821036859547ed88092e4c0 Mon Sep 17 00:00:00 2001 From: White Date: Sat, 31 Dec 2016 11:55:10 +1030 Subject: [PATCH 3/4] Re-added `/status` and added mute bool to `/v3/players/read`. `/status` is now a root endpoint and will always point to `/v2/server/status` with an added `upgrade` field describing the route to the latest status endpoint. Closes #1358. Closes #1348 --- TShockAPI/Rest/RestManager.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/TShockAPI/Rest/RestManager.cs b/TShockAPI/Rest/RestManager.cs index b62fc9dd..20e0ddb2 100644 --- a/TShockAPI/Rest/RestManager.cs +++ b/TShockAPI/Rest/RestManager.cs @@ -23,7 +23,6 @@ using System.ComponentModel; using System.IO; using System.Linq; using System.Reflection; -using System.Reflection.Emit; using System.Text; using HttpServer; using Rests; @@ -102,12 +101,14 @@ namespace TShockAPI // Server Commands if (TShock.Config.EnableTokenEndpointAuthentication) { + Rest.Register(new SecureRestCommand("/status", ServerStatusRoot)); Rest.Register(new SecureRestCommand("/v2/server/status", ServerStatusV2)); Rest.Register(new SecureRestCommand("/v3/server/motd", ServerMotd)); Rest.Register(new SecureRestCommand("/v3/server/rules", ServerRules)); } else { + Rest.Register(new RestCommand("/status", (a) => this.ServerStatusRoot(new RestRequestArgs(a.Verbs, a.Parameters, a.Request, SecureRest.TokenData.None, a.Context)))); Rest.Register(new RestCommand("/v2/server/status", (a) => this.ServerStatusV2(new RestRequestArgs(a.Verbs, a.Parameters, a.Request, SecureRest.TokenData.None, a.Context)))); Rest.Register(new RestCommand("/v3/server/motd", (a) => this.ServerMotd(new RestRequestArgs(a.Verbs, a.Parameters, a.Request, SecureRest.TokenData.None, a.Context)))); Rest.Register(new RestCommand("/v3/server/rules", (a) => this.ServerRules(new RestRequestArgs(a.Verbs, a.Parameters, a.Request, SecureRest.TokenData.None, a.Context)))); @@ -274,6 +275,16 @@ namespace TShockAPI }; } + [Description("Get a list of information about the current TShock server.")] + [Route("/status")] + [Token] + private object ServerStatusRoot(RestRequestArgs args) + { + RestObject status = (RestObject)ServerStatusV2(args); + status.Add("upgrade", "/v2/server/status"); + return status; + } + [Description("Get a list of information about the current TShock server.")] [Route("/v2/server/status")] [Token] @@ -761,10 +772,11 @@ namespace TShockAPI return new RestObject() { {"nickname", player.Name}, - {"username", null == player.User ? "" : player.User.Name}, + {"username", player.User?.Name}, {"ip", player.IP}, {"group", player.Group.Name}, - {"registered", null == player.User ? "" : player.User.Registered}, + {"registered", player.User?.Registered}, + {"muted", player.mute }, {"position", player.TileX + "," + player.TileY}, {"inventory", string.Join(", ", inventory.Select(p => (p.name + ":" + p.stack)))}, {"armor", string.Join(", ", equipment.Select(p => (p.netID + ":" + p.prefix)))}, From 6359dad213365820da984708328e2b96d8588281 Mon Sep 17 00:00:00 2001 From: White Date: Sat, 31 Dec 2016 12:57:16 +1030 Subject: [PATCH 4/4] AllowCutTilesAndBreakables option works better now. Herbs, vines, flowers can be cut inside regions if the option is enabled. Any action that would also break a wall is still ignored. Closes #1334 --- TShockAPI/GetDataHandlers.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 0a11d898..af9507fe 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -2200,8 +2200,13 @@ namespace TShockAPI return true; } } - if (TShock.Config.AllowCutTilesAndBreakables && Main.tileCut[Main.tile[tileX, tileY].type]) + if (TShock.Config.AllowCutTilesAndBreakables && Main.tileCut[tile.type]) { + if (action == EditAction.KillWall) + { + args.Player.SendTileSquare(tileX, tileY, 1); + return true; + } return false; }