1
0
mirror of https://github.com/Ylianst/MeshCentralRouter synced 2025-12-06 00:13:33 +00:00

Added support for Windows built-in OpenSSL.

This commit is contained in:
Ylian Saint-Hilaire
2021-03-02 18:32:47 -08:00
parent 31a62a585f
commit bb6c85c5a7
23 changed files with 25922 additions and 17 deletions

View File

@@ -32,6 +32,7 @@
this.cancelButton = new System.Windows.Forms.Button();
this.okButton = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.applicationComboBox = new System.Windows.Forms.ComboBox();
this.folderButton = new System.Windows.Forms.Button();
this.appNameLabel = new System.Windows.Forms.Label();
this.appLinkLabel = new System.Windows.Forms.LinkLabel();
@@ -61,6 +62,7 @@
// groupBox1
//
resources.ApplyResources(this.groupBox1, "groupBox1");
this.groupBox1.Controls.Add(this.applicationComboBox);
this.groupBox1.Controls.Add(this.folderButton);
this.groupBox1.Controls.Add(this.appNameLabel);
this.groupBox1.Controls.Add(this.appLinkLabel);
@@ -71,6 +73,14 @@
this.groupBox1.Name = "groupBox1";
this.groupBox1.TabStop = false;
//
// applicationComboBox
//
resources.ApplyResources(this.applicationComboBox, "applicationComboBox");
this.applicationComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.applicationComboBox.FormattingEnabled = true;
this.applicationComboBox.Name = "applicationComboBox";
this.applicationComboBox.SelectedIndexChanged += new System.EventHandler(this.applicationComboBox_SelectedIndexChanged);
//
// folderButton
//
resources.ApplyResources(this.folderButton, "folderButton");
@@ -149,5 +159,6 @@
private System.Windows.Forms.Label label1;
private System.Windows.Forms.OpenFileDialog openFileDialog;
private System.Windows.Forms.Button folderButton;
private System.Windows.Forms.ComboBox applicationComboBox;
}
}

View File

@@ -19,10 +19,31 @@ namespace MeshCentralRouter
UpdateInfo();
}
public class AppInfo
{
public AppInfo(string name, string link, string path, string tag) { this.name = name; this.link = link; this.path = path; this.tag = tag; }
public string name;
public string link;
public string path;
public string tag;
public override string ToString() { return name; }
}
public void SetAppName(string name) { appNameLabel.Text = name; }
public void SetAppLink(string link) { appLinkLabel.Text = link; }
public void SetAppPath(string path) { appPathTextBox.Text = path; }
public string GetAppPath() { return appPathTextBox.Text; }
public string GetAppTag() { return ((AppInfo)applicationComboBox.SelectedItem).tag; }
public void SetApps(AppInfo[] apps)
{
appNameLabel.Visible = false;
applicationComboBox.Visible = true;
foreach (AppInfo app in apps) { applicationComboBox.Items.Add(app); }
applicationComboBox.SelectedIndex = 0;
}
private void folderPictureBox_Click(object sender, EventArgs e)
{
@@ -59,5 +80,10 @@ namespace MeshCentralRouter
System.Diagnostics.Process.Start(appLinkLabel.Text);
}
private void applicationComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
appLinkLabel.Text = ((AppInfo)applicationComboBox.SelectedItem).link;
appPathTextBox.Text = ((AppInfo)applicationComboBox.SelectedItem).path;
}
}
}

View File

@@ -177,6 +177,33 @@
<data name="groupBox1.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Bottom, Left, Right</value>
</data>
<data name="applicationComboBox.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Left, Right</value>
</data>
<data name="applicationComboBox.Location" type="System.Drawing.Point, System.Drawing">
<value>86, 22</value>
</data>
<data name="applicationComboBox.Size" type="System.Drawing.Size, System.Drawing">
<value>235, 21</value>
</data>
<data name="applicationComboBox.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
</data>
<data name="applicationComboBox.Visible" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="&gt;&gt;applicationComboBox.Name" xml:space="preserve">
<value>applicationComboBox</value>
</data>
<data name="&gt;&gt;applicationComboBox.Type" xml:space="preserve">
<value>System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;applicationComboBox.Parent" xml:space="preserve">
<value>groupBox1</value>
</data>
<data name="&gt;&gt;applicationComboBox.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="folderButton.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
@@ -199,7 +226,7 @@
<value>groupBox1</value>
</data>
<data name="&gt;&gt;folderButton.ZOrder" xml:space="preserve">
<value>0</value>
<value>1</value>
</data>
<data name="appNameLabel.Font" type="System.Drawing.Font, System.Drawing">
<value>Microsoft Sans Serif, 8.25pt, style=Bold</value>
@@ -226,7 +253,7 @@
<value>groupBox1</value>
</data>
<data name="&gt;&gt;appNameLabel.ZOrder" xml:space="preserve">
<value>1</value>
<value>2</value>
</data>
<data name="appLinkLabel.Location" type="System.Drawing.Point, System.Drawing">
<value>83, 49</value>
@@ -250,7 +277,7 @@
<value>groupBox1</value>
</data>
<data name="&gt;&gt;appLinkLabel.ZOrder" xml:space="preserve">
<value>2</value>
<value>3</value>
</data>
<data name="appPathTextBox.Location" type="System.Drawing.Point, System.Drawing">
<value>86, 74</value>
@@ -271,7 +298,7 @@
<value>groupBox1</value>
</data>
<data name="&gt;&gt;appPathTextBox.ZOrder" xml:space="preserve">
<value>3</value>
<value>4</value>
</data>
<data name="label3.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -298,7 +325,7 @@
<value>groupBox1</value>
</data>
<data name="&gt;&gt;label3.ZOrder" xml:space="preserve">
<value>4</value>
<value>5</value>
</data>
<data name="label2.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -325,7 +352,7 @@
<value>groupBox1</value>
</data>
<data name="&gt;&gt;label2.ZOrder" xml:space="preserve">
<value>5</value>
<value>6</value>
</data>
<data name="label1.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@@ -352,7 +379,7 @@
<value>groupBox1</value>
</data>
<data name="&gt;&gt;label1.ZOrder" xml:space="preserve">
<value>6</value>
<value>7</value>
</data>
<data name="groupBox1.Location" type="System.Drawing.Point, System.Drawing">
<value>12, 12</value>

View File

@@ -54,6 +54,7 @@ namespace MeshCentralRouter
public bool deviceListViewMode = true;
public Process autoExitProc = null;
public int deviceDoubleClickAction = 0;
public FileInfo nativeSshPath = null;
public bool isRouterHooked()
{
@@ -266,6 +267,10 @@ namespace MeshCentralRouter
if (lines[1] != "") { label1.Text = lines[1]; }
}
catch (Exception) { }
// Check if Windows SSH is present
FileInfo nativeSshPath = new FileInfo(Path.Combine(Environment.SystemDirectory, "OpenSSH\\ssh.exe"));
if (nativeSshPath.Exists) { this.nativeSshPath = nativeSshPath; }
}
private void setDoubleClickDeviceAction()

View File

@@ -139,13 +139,25 @@ namespace MeshCentralRouter
}
if (appId == 4)
{
string appTag = null;
string appPath = null;
string puttyPath = loadFromRegistry("PuttyPath");
if ((shift == false) && (File.Exists(puttyPath)))
string openSshPath = loadFromRegistry("OpenSshPath");
if (File.Exists(puttyPath)) { appTag = "PuttyPath"; appPath = puttyPath; }
if (File.Exists(openSshPath)) { appTag = "OpenSshPath"; appPath = openSshPath; }
if ((shift == false) && (appPath != null))
{
// Launch the process
System.Diagnostics.Process proc = null;
string args = "-ssh 127.0.0.1 -P " + mapper.localport;
try { proc = System.Diagnostics.Process.Start(puttyPath, args); }
string args = null;
if (appTag == "OpenSshPath") {
SshUsernameForm f2 = new SshUsernameForm();
if (f2.ShowDialog(this) != DialogResult.OK) return;
args = "127.0.0.1 -l " + f2.Username + " -p " + mapper.localport;
}
if (appTag == "PuttyPath") { args = "-ssh 127.0.0.1 -P " + mapper.localport; }
try { proc = System.Diagnostics.Process.Start(appPath, args); }
catch (System.ComponentModel.Win32Exception) { }
// Setup auto-exit
@@ -156,17 +168,27 @@ namespace MeshCentralRouter
using (AppLaunchForm f = new AppLaunchForm())
{
System.Diagnostics.Process proc = null;
f.SetAppName(Properties.Resources.PuttyAppName);
f.SetAppLink("http://www.chiark.greenend.org.uk/~sgtatham/putty/");
f.SetAppPath(puttyPath);
AppLaunchForm.AppInfo[] apps = new AppLaunchForm.AppInfo[2];
apps[0] = new AppLaunchForm.AppInfo(Properties.Resources.OpenSSHAppName, "https://www.openssh.com/", (parent.nativeSshPath != null) ? parent.nativeSshPath.FullName : "", "OpenSshPath");
apps[1] = new AppLaunchForm.AppInfo(Properties.Resources.PuttyAppName, "http://www.chiark.greenend.org.uk/~sgtatham/putty/", puttyPath, "PuttyPath");
f.SetApps(apps);
if (f.ShowDialog(this) == DialogResult.OK)
{
saveToRegistry("PuttyPath", f.GetAppPath());
string args = "-ssh 127.0.0.1 -P " + mapper.localport;
appTag = f.GetAppTag();
appPath = f.GetAppPath();
saveToRegistry(appTag, f.GetAppPath());
string args = null;
if (appTag == "OpenSshPath") {
SshUsernameForm f2 = new SshUsernameForm();
if (f2.ShowDialog(this) != DialogResult.OK) return;
args = "127.0.0.1 -l " + f2.Username + " -p " + mapper.localport; saveToRegistry("PuttyPath", "");
}
if (appTag == "PuttyPath") { args = "-ssh 127.0.0.1 -P " + mapper.localport; saveToRegistry("OpenSshPath", ""); }
if (args == null) return;
// Launch the process
try { proc = System.Diagnostics.Process.Start(f.GetAppPath(), args); }
catch (System.ComponentModel.Win32Exception) { }
try { proc = System.Diagnostics.Process.Start(appPath, args); } catch (Win32Exception) { }
// Setup auto-exit
if ((autoexit == true) && (parent.autoExitProc == null)) { parent.autoExitProc = proc; parent.SetAutoClose(); autoExitTimer.Enabled = true; }

View File

@@ -94,6 +94,12 @@
<Compile Include="AddRelayMapForm.designer.cs">
<DependentUpon>AddRelayMapForm.cs</DependentUpon>
</Compile>
<Compile Include="SshUsernameForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SshUsernameForm.Designer.cs">
<DependentUpon>SshUsernameForm.cs</DependentUpon>
</Compile>
<Compile Include="AppLaunchForm.cs">
<SubType>Form</SubType>
</Compile>
@@ -320,6 +326,45 @@
<EmbeddedResource Include="AddRelayMapForm.zh-chs.resx">
<DependentUpon>AddRelayMapForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="SshUsernameForm.cs.resx">
<DependentUpon>SshUsernameForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="SshUsernameForm.de.resx">
<DependentUpon>SshUsernameForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="SshUsernameForm.es.resx">
<DependentUpon>SshUsernameForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="SshUsernameForm.fr.resx">
<DependentUpon>SshUsernameForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="SshUsernameForm.hi.resx">
<DependentUpon>SshUsernameForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="SshUsernameForm.it.resx">
<DependentUpon>SshUsernameForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="SshUsernameForm.ja.resx">
<DependentUpon>SshUsernameForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="SshUsernameForm.ko.resx">
<DependentUpon>SshUsernameForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="SshUsernameForm.nl.resx">
<DependentUpon>SshUsernameForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="SshUsernameForm.pt.resx">
<DependentUpon>SshUsernameForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="SshUsernameForm.resx">
<DependentUpon>SshUsernameForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="SshUsernameForm.ru.resx">
<DependentUpon>SshUsernameForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="SshUsernameForm.zh-chs.resx">
<DependentUpon>SshUsernameForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="altPortForm.cs.resx">
<DependentUpon>altPortForm.cs</DependentUpon>
</EmbeddedResource>

View File

@@ -374,6 +374,15 @@ namespace MeshCentralRouter.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to OpenSSH.
/// </summary>
internal static string OpenSSHAppName {
get {
return ResourceManager.GetString("OpenSSHAppName", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to PuTTY SSH client.
/// </summary>

View File

@@ -265,4 +265,7 @@
<data name="arrowleft16" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\arrowleft16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="OpenSSHAppName" xml:space="preserve">
<value>OpenSSH</value>
</data>
</root>

102
SshUsernameForm.Designer.cs generated Normal file
View File

@@ -0,0 +1,102 @@
namespace MeshCentralRouter
{
partial class SshUsernameForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SshUsernameForm));
this.cancelButton = new System.Windows.Forms.Button();
this.okButton = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label2 = new System.Windows.Forms.Label();
this.usernameTextBox = new System.Windows.Forms.TextBox();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// cancelButton
//
resources.ApplyResources(this.cancelButton, "cancelButton");
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.cancelButton.Name = "cancelButton";
this.cancelButton.UseVisualStyleBackColor = true;
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
//
// okButton
//
resources.ApplyResources(this.okButton, "okButton");
this.okButton.Name = "okButton";
this.okButton.UseVisualStyleBackColor = true;
this.okButton.Click += new System.EventHandler(this.okButton_Click);
//
// groupBox1
//
resources.ApplyResources(this.groupBox1, "groupBox1");
this.groupBox1.Controls.Add(this.usernameTextBox);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Name = "groupBox1";
this.groupBox1.TabStop = false;
//
// label2
//
resources.ApplyResources(this.label2, "label2");
this.label2.Name = "label2";
//
// usernameTextBox
//
resources.ApplyResources(this.usernameTextBox, "usernameTextBox");
this.usernameTextBox.Name = "usernameTextBox";
this.usernameTextBox.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
//
// SshUsernameForm
//
this.AcceptButton = this.okButton;
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.cancelButton;
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.okButton);
this.Controls.Add(this.cancelButton);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "SshUsernameForm";
this.Load += new System.EventHandler(this.SshUsernameForm_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button cancelButton;
private System.Windows.Forms.Button okButton;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox usernameTextBox;
}
}

45
SshUsernameForm.cs Normal file
View File

@@ -0,0 +1,45 @@
using System;
using System.Windows.Forms;
namespace MeshCentralRouter
{
public partial class SshUsernameForm : Form
{
public SshUsernameForm()
{
InitializeComponent();
}
public string Username
{
get { return usernameTextBox.Text; }
set { usernameTextBox.Text = value; updateInfo(); }
}
private void okButton_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
}
private void cancelButton_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
}
public void updateInfo()
{
okButton.Enabled = (usernameTextBox.Text.Length > 0) && (usernameTextBox.Text.IndexOf(" ") == -1);
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
updateInfo();
}
private void SshUsernameForm_Load(object sender, EventArgs e)
{
updateInfo();
usernameTextBox.Focus();
}
}
}

1970
SshUsernameForm.cs.resx Normal file

File diff suppressed because it is too large Load Diff

1970
SshUsernameForm.de.resx Normal file

File diff suppressed because it is too large Load Diff

1970
SshUsernameForm.es.resx Normal file

File diff suppressed because it is too large Load Diff

1970
SshUsernameForm.fr.resx Normal file

File diff suppressed because it is too large Load Diff

1970
SshUsernameForm.hi.resx Normal file

File diff suppressed because it is too large Load Diff

1970
SshUsernameForm.it.resx Normal file

File diff suppressed because it is too large Load Diff

1970
SshUsernameForm.ja.resx Normal file

File diff suppressed because it is too large Load Diff

1970
SshUsernameForm.ko.resx Normal file

File diff suppressed because it is too large Load Diff

1970
SshUsernameForm.nl.resx Normal file

File diff suppressed because it is too large Load Diff

1970
SshUsernameForm.pt.resx Normal file

File diff suppressed because it is too large Load Diff

1970
SshUsernameForm.resx Normal file

File diff suppressed because it is too large Load Diff

1970
SshUsernameForm.ru.resx Normal file

File diff suppressed because it is too large Load Diff

1970
SshUsernameForm.zh-chs.resx Normal file

File diff suppressed because it is too large Load Diff