Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Source/NETworkManager.Localization/Resources/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Source/NETworkManager.Localization/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2851,4 +2851,13 @@ URL: https://github.com/BornToBeRoot/NETworkManager/tree/master/Documentation</v
<data name="SettingsViewName_Window" xml:space="preserve">
<value>Window</value>
</data>
<data name="EnableSessionLog" xml:space="preserve">
<value>Enable session log</value>
</data>
<data name="SessionLogFileName" xml:space="preserve">
<value>Session log file name</value>
</data>
<data name="SessionLogPath" xml:space="preserve">
<value>Session log path</value>
</data>
</root>
4 changes: 4 additions & 0 deletions Source/NETworkManager.Models/PuTTY/PuTTY.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public static string BuildCommandLine(PuTTYSessionInfo profileInfo)
if (!string.IsNullOrEmpty(profileInfo.Username))
command += $" -l {profileInfo.Username}";

// Session log
if (profileInfo.EnableSessionLog)
command += $" -sessionlog {'"'}{ profileInfo.SessionLogFullName}{'"'}";

// Additional commands
if (!string.IsNullOrEmpty(profileInfo.AdditionalCommandLine))
command += $" {profileInfo.AdditionalCommandLine}";
Expand Down
45 changes: 44 additions & 1 deletion Source/NETworkManager.Models/PuTTY/PuTTYSessionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,59 @@

namespace NETworkManager.Models.PuTTY
{
/// <summary>
/// Stores informations about a putty session.
/// </summary>
public class PuTTYSessionInfo
{
/// <summary>
/// Full path to the PuTTY.exe on the filesystem.
/// </summary>
public string ApplicationFilePath { get; set; }

/// <summary>
/// Mode (SSH, Telnet, etc.), which is used to establish the connection.
/// </summary>
public ConnectionMode Mode { get; set; }

/// <summary>
/// Hostname or SerialLine. Depends on the <see cref="ConnectionMode"/>.
/// </summary>
public string HostOrSerialLine { get; set; }

/// <summary>
/// Port or Baud. Depends on the <see cref="ConnectionMode"/>.
/// </summary>
public int PortOrBaud { get; set; }
public string Profile { get; set; }

/// <summary>
/// Username for login.
/// </summary>
public string Username { get; set; }

/// <summary>
/// PuTTY profile to use.
/// </summary>
public string Profile { get; set; }

/// <summary>
/// Enables session log.
/// </summary>
public bool EnableSessionLog { get; set; }

/// <summary>
/// Path and filename of the session log file (e.g. "C:\..\PuTTY.log").
/// </summary>
public string SessionLogFullName { get; set; }

/// <summary>
/// Additional command line argument. Everything putty can handle.
/// </summary>
public string AdditionalCommandLine { get; set; }

/// <summary>
/// Initializes a new instance of the <see cref="PuTTYSessionInfo"/> class.
/// </summary>
public PuTTYSessionInfo()
{

Expand Down
4 changes: 4 additions & 0 deletions Source/NETworkManager.Profiles/Application/PuTTY.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using NETworkManager.Models.PuTTY;
using NETworkManager.Settings;
using System.IO;
using System;

namespace NETworkManager.Profiles.Application
{
Expand All @@ -14,6 +16,8 @@ public static PuTTYSessionInfo CreateSessionInfo(ProfileInfo profileInfo)
PortOrBaud = profileInfo.PuTTY_OverridePortOrBaud ? profileInfo.PuTTY_PortOrBaud : Settings.Application.PuTTY.GetPortOrBaudByConnectionMode(profileInfo.PuTTY_ConnectionMode),
Username = profileInfo.PuTTY_OverrideUsername ? profileInfo.PuTTY_Username : SettingsManager.Current.PuTTY_Username,
Profile = profileInfo.PuTTY_OverrideProfile ? profileInfo.PuTTY_Profile : SettingsManager.Current.PuTTY_Profile,
EnableSessionLog = profileInfo.PuTTY_OverrideEnableSessionLog ? profileInfo.PuTTY_EnableSessionLog : SettingsManager.Current.PuTTY_EnableSessionLog,
SessionLogFullName = Environment.ExpandEnvironmentVariables(Path.Combine(SettingsManager.Current.PuTTY_SessionLogPath, profileInfo.PuTTY_OverrideSessionLogFileName ? profileInfo.PuTTY_SessionLogFileName : SettingsManager.Current.PuTTY_SessionLogFileName)),
AdditionalCommandLine = profileInfo.PuTTY_OverrideAdditionalCommandLine ? profileInfo.PuTTY_AdditionalCommandLine : SettingsManager.Current.PuTTY_AdditionalCommandLine
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\NETworkManager.Profiles.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand Down
8 changes: 8 additions & 0 deletions Source/NETworkManager.Profiles/ProfileInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,13 @@ public class ProfileInfo
public string PuTTY_Username { get; set; }
public bool PuTTY_OverrideProfile { get; set; }
public string PuTTY_Profile { get; set; }
public bool PuTTY_OverrideEnableSessionLog { get; set; }
public bool PuTTY_EnableSessionLog { get; set; }
public bool PuTTY_OverrideSessionLogFileName { get; set; }
public string PuTTY_SessionLogFileName { get; set; } = GlobalStaticConfiguration.PuTTY_SessionLogFileName;
public bool PuTTY_OverrideAdditionalCommandLine { get; set; }
public string PuTTY_AdditionalCommandLine { get; set; }


public bool TigerVNC_Enabled { get; set; }
public bool TigerVNC_InheritHost { get; set; } = true;
Expand All @@ -149,6 +154,9 @@ public class ProfileInfo
public bool Whois_InheritHost { get; set; } = true;
public string Whois_Domain { get; set; }

/// <summary>
/// Initializes a new instance of the<see cref="ProfileInfo"/> class.
/// </summary>
public ProfileInfo()
{

Expand Down
34 changes: 1 addition & 33 deletions Source/NETworkManager.Profiles/ProfileManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@

namespace NETworkManager.Profiles
{
/// <summary>
///
/// </summary>
public static class ProfileManager
{
#region Variables
Expand All @@ -36,24 +33,12 @@ public static class ProfileManager
/// </summary>
public static string ProfilesEncryptionIdentifier => ".encrypted";

/// <summary>
///
/// </summary>
public static string TagIdentifier => "tag=";

/// <summary>
///
/// </summary>
public static ObservableCollection<ProfileFileInfo> ProfileFiles { get; set; } = new ObservableCollection<ProfileFileInfo>();

/// <summary>
///
/// </summary>
private static ProfileFileInfo _profileFileInfo;

/// <summary>
///
/// </summary>
public static ProfileFileInfo LoadedProfileFile
{
get => _profileFileInfo;
Expand All @@ -66,25 +51,12 @@ public static ProfileFileInfo LoadedProfileFile
}
}

/// <summary>
///
/// </summary>
public static ObservableCollection<ProfileInfo> Profiles { get; set; } = new ObservableCollection<ProfileInfo>();

/// <summary>
///
/// </summary>

public static bool ProfilesChanged { get; set; }

/// <summary>
///
/// </summary>
public static event EventHandler<ProfileFileInfoArgs> OnProfileFileChangedEvent;

/// <summary>
///
/// </summary>
/// <param name="profileFileInfo"></param>
private static void ProfileFileChanged(ProfileFileInfo profileFileInfo)
{
OnProfileFileChangedEvent?.Invoke(null, new ProfileFileInfoArgs(profileFileInfo));
Expand Down Expand Up @@ -118,10 +90,6 @@ public static string GetPortableProfilesLocation()
return Path.Combine(Path.GetDirectoryName(AssemblyManager.Current.Location) ?? throw new InvalidOperationException(), ProfilesFolderName);
}

/// <summary>
///
/// </summary>
/// <returns></returns>
public static string GetProfilesLocation()
{
return ConfigurationManager.Current.IsPortable ? GetPortableProfilesLocation() : GetProfilesLocationNotPortable();
Expand Down
2 changes: 2 additions & 0 deletions Source/NETworkManager.Settings/GlobalStaticConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ public static class GlobalStaticConfiguration

// Application: PuTTY
public static PuTTY.ConnectionMode PuTTY_DefaultConnectionMode => PuTTY.ConnectionMode.SSH;
public static string PuTTY_SessionLogPath => Path.Combine("%LocalAppData%", AssemblyManager.Current.Name, "PuTTY_LogFiles");
public static string PuTTY_SessionLogFileName => "&H_&Y-&M-&D_&T.log";
public static int PuTTY_SSHPort => 22;
public static string PuTTY_SerialLine => "COM1";
public static int PuTTY_TelnetPort => 23;
Expand Down
45 changes: 45 additions & 0 deletions Source/NETworkManager.Settings/SettingsInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2589,6 +2589,51 @@ public string PuTTY_Profile
}
}

private bool _puTTY_EnableSessionLog;
public bool PuTTY_EnableSessionLog
{
get => _puTTY_EnableSessionLog;
set
{
if (value == _puTTY_EnableSessionLog)
return;

_puTTY_EnableSessionLog = value;
OnPropertyChanged();
SettingsChanged = true;
}
}

private string _puTTY_SessionLogPath = GlobalStaticConfiguration.PuTTY_SessionLogPath;
public string PuTTY_SessionLogPath
{
get => _puTTY_SessionLogPath;
set
{
if (value == _puTTY_SessionLogPath)
return;

_puTTY_SessionLogPath = value;
OnPropertyChanged();
SettingsChanged = true;
}
}

private string _puTTY_SessionLogFileName = GlobalStaticConfiguration.PuTTY_SessionLogFileName;
public string PuTTY_SessionLogFileName
{
get => _puTTY_SessionLogFileName;
set
{
if (value == _puTTY_SessionLogFileName)
return;

_puTTY_SessionLogFileName = value;
OnPropertyChanged();
SettingsChanged = true;
}
}

private string _puTTY_AdditionalCommandLine;
public string PuTTY_AdditionalCommandLine
{
Expand Down
21 changes: 21 additions & 0 deletions Source/NETworkManager.Utilities/DirectoryCreator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.IO;


namespace NETworkManager.Utilities
{
/// <summary>
/// Contains methods to create a directory with sub directories.
/// </summary>
public static class DirectoryCreator
{
/// <summary>
/// Create a directory with subdirectories and resolve environment variables.
/// </summary>
/// <param name="path">Path like "%AppDataLocal%\Folder1".</param>
public static void CreateWithEnvironmentVariables(string path)
{
Directory.CreateDirectory(Environment.ExpandEnvironmentVariables(path));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<Compile Include="ClipboardHelper.cs" />
<Compile Include="CustomCommand.cs" />
<Compile Include="CustomCommandInfo.cs" />
<Compile Include="DirectoryCreator.cs" />
<Compile Include="DnsLookupHelper.cs" />
<Compile Include="FileCryptoManager.cs" />
<Compile Include="FileSizeConverter.cs" />
Expand Down
2 changes: 1 addition & 1 deletion Source/NETworkManager/Controls/PuTTYControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
xmlns:converters="clr-namespace:NETworkManager.Converters;assembly=NETworkManager.Converters"
xmlns:windowsForms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
xmlns:localization="clr-namespace:NETworkManager.Localization.Resources;assembly=NETworkManager.Localization"
xmlns:networkManagerControls="clr-namespace:NETworkManager.Controls"
xmlns:networkManagerControls="clr-namespace:NETworkManager.Controls;assembly=NETworkManager"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
mah:DialogParticipation.Register="{Binding}"
mc:Ignorable="d" Loaded="UserControl_Loaded" d:DataContext="{d:DesignInstance networkManagerControls:PuTTYControl}">
Expand Down
3 changes: 3 additions & 0 deletions Source/NETworkManager/Controls/PuTTYControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ private async void Connect()
{
IsConnecting = true;

// Create log path
DirectoryCreator.CreateWithEnvironmentVariables(SettingsManager.Current.PuTTY_SessionLogPath);

var info = new ProcessStartInfo
{
FileName = _sessionInfo.ApplicationFilePath,
Expand Down
2 changes: 1 addition & 1 deletion Source/NETworkManager/Controls/RemoteDesktopControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
xmlns:converters="clr-namespace:NETworkManager.Converters;assembly=NETworkManager.Converters"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:localization="clr-namespace:NETworkManager.Localization.Resources;assembly=NETworkManager.Localization"
xmlns:networkManagerControls="clr-namespace:NETworkManager.Controls"
xmlns:networkManagerControls="clr-namespace:NETworkManager.Controls;assembly=NETworkManager"
mc:Ignorable="d" Loaded="UserControl_Loaded" d:DataContext="{d:DesignInstance networkManagerControls:RemoteDesktopControl}">
<UserControl.Resources>
<converters:BooleanReverseConverter x:Key="BooleanReverseConverter" />
Expand Down
2 changes: 1 addition & 1 deletion Source/NETworkManager/Controls/TightVNCControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
xmlns:converters="clr-namespace:NETworkManager.Converters;assembly=NETworkManager.Converters"
xmlns:windowsForms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
xmlns:localization="clr-namespace:NETworkManager.Localization.Resources;assembly=NETworkManager.Localization"
xmlns:networkManagerControls="clr-namespace:NETworkManager.Controls"
xmlns:networkManagerControls="clr-namespace:NETworkManager.Controls;assembly=NETworkManager"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
mah:DialogParticipation.Register="{Binding}"
mc:Ignorable="d" Loaded="UserControl_Loaded" d:DataContext="{d:DesignInstance networkManagerControls:TigerVNCControl}">
Expand Down
2 changes: 1 addition & 1 deletion Source/NETworkManager/Controls/WebConsoleControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:networkManagerControls="clr-namespace:NETworkManager.Controls"
xmlns:networkManagerControls="clr-namespace:NETworkManager.Controls;assembly=NETworkManager"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:localization="clr-namespace:NETworkManager.Localization.Resources;assembly=NETworkManager.Localization"
xmlns:converters="clr-namespace:NETworkManager.Converters;assembly=NETworkManager.Converters"
Expand Down
Loading