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.
This commit is contained in:
parent
36904b673f
commit
4f7a15f9bf
1 changed files with 18 additions and 0 deletions
|
|
@ -822,6 +822,7 @@ namespace TShockAPI
|
|||
|
||||
/// <summary>AuthToken - The auth token used by the /auth system to grant temporary superadmin access to new admins.</summary>
|
||||
public static int AuthToken = -1;
|
||||
private string _cliPassword = null;
|
||||
|
||||
/// <summary>OnPostInit - Fired when the server loads a map, to perform world specific operations.</summary>
|
||||
/// <param name="args">args - The EventArgs object.</param>
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue