* Implementing SSH (changes from ap/ssh branch). * Implemented opening links in the last active window. * Using settings to determine where to open link (tab or window). * Adding FluentTerminal.App_TemporaryKey.pfx back to repo, to solve bug with keys. * App activation on mosh schema launching; mosh protocol parsing. (#35) * SSH handling changed to improve links. * Creating shortcuts from SSH dialog. * Trivial Mosh checkbox label fix It's "Mosh" not "MOSH". * Obtain mosh key from ssh connection (#40) * Prepopulate SSH username with Windows username (#50) * Undoing Max's mosh authentication changes. * Adding the new mosh wrapper. * Request user name from tray process (#51) * Mosh implemented, but still doesn't work (cannot find mosh.exe). * Add New Remote Shell menu; Rename New Tab into New Local Shell (#52) * Mosh works like charm. * Mosh wrapper improved to print an error. * Changing mosh wrapper to always exit with 0 (to ensure that the tab gets closed). * Changing mosh wrapper again to return error codes. * Slightly optimizing getting the username. * Saving links improved. * Fixed an issue in mosh wrapper, related to mosh to hostname. * mosh-client.exe updated with 32 bit version for x86 platform (#59) * Set line endings for remote shell connection; Left focus on SSH info dialog if input validation error occured; Update DataContext object on each key entered into target host text box control. * Simplifying SSH dialog. * Fixing some leftovers after merging. * Fixing some after-merge issues. * Avoiding some unintentional upstream changes. * Fix review findings
119 lines
3.3 KiB
C#
119 lines
3.3 KiB
C#
using System.Collections.ObjectModel;
|
|
using FluentTerminal.App.Services;
|
|
using GalaSoft.MvvmLight;
|
|
using FluentTerminal.Models.Enums;
|
|
|
|
namespace FluentTerminal.App.ViewModels
|
|
{
|
|
public class SshConnectionInfoViewModel : ViewModelBase, ISshConnectionInfo
|
|
{
|
|
public const ushort DefaultSshPort = 22;
|
|
public const ushort DefaultMoshPortsFrom = 60000;
|
|
public const ushort DefaultMoshPortsTo = 60050;
|
|
|
|
private string _host = string.Empty;
|
|
|
|
public string Host
|
|
{
|
|
get => _host;
|
|
set => Set(ref _host, value);
|
|
}
|
|
|
|
private ushort _sshPort = DefaultSshPort;
|
|
|
|
public ushort SshPort
|
|
{
|
|
get => _sshPort;
|
|
set => Set(ref _sshPort, value);
|
|
}
|
|
|
|
private string _username = string.Empty;
|
|
|
|
public string Username
|
|
{
|
|
get => _username;
|
|
set => Set(ref _username, value);
|
|
}
|
|
|
|
private string _identityFile = string.Empty;
|
|
|
|
public string IdentityFile
|
|
{
|
|
get => _identityFile;
|
|
set => Set(ref _identityFile, value);
|
|
}
|
|
|
|
private bool _useMosh;
|
|
|
|
public bool UseMosh
|
|
{
|
|
get => _useMosh;
|
|
set => Set(ref _useMosh, value);
|
|
}
|
|
|
|
private ushort _moshPortFrom = DefaultMoshPortsFrom;
|
|
|
|
public ushort MoshPortFrom
|
|
{
|
|
get => _moshPortFrom;
|
|
set => Set(ref _moshPortFrom, value);
|
|
}
|
|
|
|
private ushort _moshPortTo = DefaultMoshPortsTo;
|
|
|
|
public ushort MoshPortTo
|
|
{
|
|
get => _moshPortTo;
|
|
set => Set(ref _moshPortTo, value);
|
|
}
|
|
|
|
private LineEndingStyle _lineEndingStyle = LineEndingStyle.ToLF;
|
|
|
|
public LineEndingStyle LineEndingStyle
|
|
{
|
|
get => _lineEndingStyle;
|
|
set => Set(ref _lineEndingStyle, value);
|
|
}
|
|
|
|
public ObservableCollection<SshOptionViewModel> SshOptions { get; } =
|
|
new ObservableCollection<SshOptionViewModel>();
|
|
|
|
public string Validate(bool allowNoUser = false)
|
|
{
|
|
if (!allowNoUser && string.IsNullOrEmpty(_username))
|
|
return "Username cannot be empty.";
|
|
|
|
if (string.IsNullOrEmpty(_host))
|
|
return "Host cannot be empty.";
|
|
|
|
if (_sshPort < 1)
|
|
return "SSH port has to be greater than zero.";
|
|
|
|
if (!_useMosh)
|
|
return null;
|
|
|
|
if (_moshPortFrom < 1)
|
|
return "Mosh port cannot be zero.";
|
|
|
|
if (_moshPortFrom > _moshPortTo)
|
|
return "Mosh port range is invalid.";
|
|
|
|
return null;
|
|
}
|
|
|
|
public SshConnectionInfoViewModel Clone()
|
|
{
|
|
SshConnectionInfoViewModel clone = new SshConnectionInfoViewModel
|
|
{
|
|
_host = _host, _sshPort = _sshPort, _username = _username, _identityFile = _identityFile,
|
|
_useMosh = _useMosh, _moshPortFrom = _moshPortFrom, _moshPortTo = _moshPortTo,
|
|
_lineEndingStyle = _lineEndingStyle
|
|
};
|
|
|
|
foreach (SshOptionViewModel option in SshOptions)
|
|
clone.SshOptions.Add(option);
|
|
|
|
return clone;
|
|
}
|
|
}
|
|
} |