mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-25 22:17:51 +01:00
RemoteLoginInfo sanity checking
This commit is contained in:
@@ -20,6 +20,11 @@ namespace TGS.Interface
|
||||
/// A Windows username for the target server
|
||||
/// </summary>
|
||||
public string Username { get; }
|
||||
/// <summary>
|
||||
/// Check if the <see cref="RemoteLoginInfo"/> has been initialized with a <see cref="Password"/>
|
||||
/// </summary>
|
||||
public bool HasPassword { get { return !String.IsNullOrWhiteSpace(Password); } }
|
||||
|
||||
/// <summary>
|
||||
/// The Windows password for <see cref="Username"/>
|
||||
/// </summary>
|
||||
@@ -51,8 +56,14 @@ namespace TGS.Interface
|
||||
/// <param name="password">The value for <see cref="Password"/></param>
|
||||
public RemoteLoginInfo(string ip, ushort port, string username, string password)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(ip))
|
||||
throw new InvalidOperationException("ip must be set!");
|
||||
_ip = ip;
|
||||
if(port == 0)
|
||||
throw new InvalidOperationException("port may not be 0!");
|
||||
_port = port;
|
||||
if (String.IsNullOrWhiteSpace(username))
|
||||
throw new InvalidOperationException("username must be set!");
|
||||
_username = username;
|
||||
_password = password;
|
||||
}
|
||||
|
||||
@@ -216,6 +216,8 @@ namespace TGS.Interface
|
||||
/// <param name="loginInfo">The <see cref="RemoteLoginInfo"/> for a remote connection</param>
|
||||
public ServerInterface(RemoteLoginInfo loginInfo)
|
||||
{
|
||||
if (!loginInfo.HasPassword)
|
||||
throw new InvalidOperationException("password must be set on loginInfo!");
|
||||
_loginInfo = loginInfo;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user