Files
FluentTerminal/FluentTerminal.Models/SshConnectionInfoExtensions.cs
T
Aleksandar Pesic 4ec9f0a5a6 Implementing remote SSH profiles, 2nd attempt (#395)
* Implementing remote SSH profiles.

* Fixing async terminal adds.

* Improving behavior when new window is requested.

* Minor changes.

* Move ssh profiles to roaming, rename sshshellprofile to sshprofile
2019-06-07 00:22:45 +02:00

46 lines
1.4 KiB
C#

using FluentTerminal.Models.Enums;
namespace FluentTerminal.Models
{
public static class SshConnectionInfoExtensions
{
public static SshConnectionInfoValidationResult GetValidationResult(this ISshConnectionInfo sshConnectionInfo,
bool allowNoUser = false)
{
var result = SshConnectionInfoValidationResult.Valid;
if (!allowNoUser && string.IsNullOrEmpty(sshConnectionInfo.Username))
{
result |= SshConnectionInfoValidationResult.UsernameEmpty;
}
if (string.IsNullOrEmpty(sshConnectionInfo.Host))
{
result |= SshConnectionInfoValidationResult.HostEmpty;
}
if (sshConnectionInfo.SshPort < 1)
{
result |= SshConnectionInfoValidationResult.SshPortZeroOrNegative;
}
if (!sshConnectionInfo.UseMosh)
{
return result;
}
if (sshConnectionInfo.MoshPortFrom < 1)
{
result |= SshConnectionInfoValidationResult.MoshPortZeroOrNegative;
}
if (sshConnectionInfo.MoshPortFrom > sshConnectionInfo.MoshPortTo)
{
result |= SshConnectionInfoValidationResult.MoshPortRangeInvalid;
}
return result;
}
}
}