1
0
mirror of https://github.com/Ylianst/MeshCentralRouter synced 2025-12-10 13:23:49 +00:00

Added load/save mappings.

This commit is contained in:
Ylian Saint-Hilaire
2020-07-03 15:29:15 -07:00
parent c397603666
commit 42f39fd558
6 changed files with 290 additions and 59 deletions

View File

@@ -269,7 +269,7 @@
<value>62, 12</value> <value>62, 12</value>
</data> </data>
<data name="deviceNameLabel.Size" type="System.Drawing.Size, System.Drawing"> <data name="deviceNameLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>243, 15</value> <value>235, 15</value>
</data> </data>
<data name="deviceNameLabel.TabIndex" type="System.Int32, mscorlib"> <data name="deviceNameLabel.TabIndex" type="System.Int32, mscorlib">
<value>1</value> <value>1</value>
@@ -296,7 +296,7 @@
<value>62, 32</value> <value>62, 32</value>
</data> </data>
<data name="deviceStatusLabel.Size" type="System.Drawing.Size, System.Drawing"> <data name="deviceStatusLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>243, 15</value> <value>235, 15</value>
</data> </data>
<data name="deviceStatusLabel.TabIndex" type="System.Int32, mscorlib"> <data name="deviceStatusLabel.TabIndex" type="System.Int32, mscorlib">
<value>2</value> <value>2</value>
@@ -322,12 +322,6 @@
<metadata name="rdpContextMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="rdpContextMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>313, 17</value> <value>313, 17</value>
</metadata> </metadata>
<data name="setRDPPortToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>149, 22</value>
</data>
<data name="setRDPPortToolStripMenuItem.Text" xml:space="preserve">
<value>Set RDP port...</value>
</data>
<data name="rdpContextMenuStrip.Size" type="System.Drawing.Size, System.Drawing"> <data name="rdpContextMenuStrip.Size" type="System.Drawing.Size, System.Drawing">
<value>150, 26</value> <value>150, 26</value>
</data> </data>
@@ -338,7 +332,7 @@
<value>System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data> </data>
<data name="rdpButton.Location" type="System.Drawing.Point, System.Drawing"> <data name="rdpButton.Location" type="System.Drawing.Point, System.Drawing">
<value>375, 6</value> <value>367, 6</value>
</data> </data>
<data name="rdpButton.Size" type="System.Drawing.Size, System.Drawing"> <data name="rdpButton.Size" type="System.Drawing.Size, System.Drawing">
<value>58, 47</value> <value>58, 47</value>
@@ -361,6 +355,12 @@
<data name="&gt;&gt;rdpButton.ZOrder" xml:space="preserve"> <data name="&gt;&gt;rdpButton.ZOrder" xml:space="preserve">
<value>6</value> <value>6</value>
</data> </data>
<data name="setRDPPortToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>149, 22</value>
</data>
<data name="setRDPPortToolStripMenuItem.Text" xml:space="preserve">
<value>Set RDP port...</value>
</data>
<metadata name="deviceImageList.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="deviceImageList.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value> <value>17, 17</value>
</metadata> </metadata>
@@ -369,7 +369,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAy ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAy
mgAAAk1TRnQBSQFMAgEBCAEAAWABAAFgAQABMgEAATIBAAT/AREBAAj/AUIBTQE2BwABNgMAASgDAAHI mgAAAk1TRnQBSQFMAgEBCAEAAWgBAAFoAQABMgEAATIBAAT/AREBAAj/AUIBTQE2BwABNgMAASgDAAHI
AwABlgMAAQEBAAEQBQABYAHq/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A AwABlgMAAQEBAAEQBQABYAHq/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A
/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A /wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A
/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A /wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A
@@ -1037,7 +1037,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAC4 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAC4
mgAAAk1TRnQBSQFMAgEBCAEAAWgBAAFoAQABMgEAATIBAAT/AREBAAj/AUIBTQE2BwABNgMAASgDAAHI mgAAAk1TRnQBSQFMAgEBCAEAAXABAAFwAQABMgEAATIBAAT/AREBAAj/AUIBTQE2BwABNgMAASgDAAHI
AwABlgMAAQEBAAEQBQABYAHq/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A AwABlgMAAQEBAAEQBQABYAHq/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A
/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A /wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A
/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A /wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A
@@ -1706,12 +1706,6 @@
<metadata name="altPortContextMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="altPortContextMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>468, 17</value> <value>468, 17</value>
</metadata> </metadata>
<data name="toolStripMenuItem1.Size" type="System.Drawing.Size, System.Drawing">
<value>178, 22</value>
</data>
<data name="toolStripMenuItem1.Text" xml:space="preserve">
<value>Use Alternate Port...</value>
</data>
<data name="altPortContextMenuStrip.Size" type="System.Drawing.Size, System.Drawing"> <data name="altPortContextMenuStrip.Size" type="System.Drawing.Size, System.Drawing">
<value>179, 26</value> <value>179, 26</value>
</data> </data>
@@ -1722,7 +1716,7 @@
<value>System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data> </data>
<data name="httpsButton.Location" type="System.Drawing.Point, System.Drawing"> <data name="httpsButton.Location" type="System.Drawing.Point, System.Drawing">
<value>311, 6</value> <value>303, 6</value>
</data> </data>
<data name="httpsButton.Size" type="System.Drawing.Size, System.Drawing"> <data name="httpsButton.Size" type="System.Drawing.Size, System.Drawing">
<value>58, 23</value> <value>58, 23</value>
@@ -1745,11 +1739,17 @@
<data name="&gt;&gt;httpsButton.ZOrder" xml:space="preserve"> <data name="&gt;&gt;httpsButton.ZOrder" xml:space="preserve">
<value>5</value> <value>5</value>
</data> </data>
<data name="toolStripMenuItem1.Size" type="System.Drawing.Size, System.Drawing">
<value>178, 22</value>
</data>
<data name="toolStripMenuItem1.Text" xml:space="preserve">
<value>Use Alternate Port...</value>
</data>
<data name="httpButton.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms"> <data name="httpButton.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value> <value>Top, Right</value>
</data> </data>
<data name="httpButton.Location" type="System.Drawing.Point, System.Drawing"> <data name="httpButton.Location" type="System.Drawing.Point, System.Drawing">
<value>311, 30</value> <value>303, 30</value>
</data> </data>
<data name="httpButton.Size" type="System.Drawing.Size, System.Drawing"> <data name="httpButton.Size" type="System.Drawing.Size, System.Drawing">
<value>58, 23</value> <value>58, 23</value>
@@ -1776,7 +1776,7 @@
<value>Top, Right</value> <value>Top, Right</value>
</data> </data>
<data name="scpButton.Location" type="System.Drawing.Point, System.Drawing"> <data name="scpButton.Location" type="System.Drawing.Point, System.Drawing">
<value>375, 30</value> <value>367, 30</value>
</data> </data>
<data name="scpButton.Size" type="System.Drawing.Size, System.Drawing"> <data name="scpButton.Size" type="System.Drawing.Size, System.Drawing">
<value>58, 23</value> <value>58, 23</value>
@@ -1803,7 +1803,7 @@
<value>Top, Right</value> <value>Top, Right</value>
</data> </data>
<data name="sshButton.Location" type="System.Drawing.Point, System.Drawing"> <data name="sshButton.Location" type="System.Drawing.Point, System.Drawing">
<value>375, 6</value> <value>367, 6</value>
</data> </data>
<data name="sshButton.Size" type="System.Drawing.Size, System.Drawing"> <data name="sshButton.Size" type="System.Drawing.Size, System.Drawing">
<value>58, 23</value> <value>58, 23</value>
@@ -1833,7 +1833,7 @@
<value>6, 13</value> <value>6, 13</value>
</data> </data>
<data name="$this.Size" type="System.Drawing.Size, System.Drawing"> <data name="$this.Size" type="System.Drawing.Size, System.Drawing">
<value>437, 56</value> <value>433, 60</value>
</data> </data>
<data name="&gt;&gt;setRDPPortToolStripMenuItem.Name" xml:space="preserve"> <data name="&gt;&gt;setRDPPortToolStripMenuItem.Name" xml:space="preserve">
<value>setRDPPortToolStripMenuItem</value> <value>setRDPPortToolStripMenuItem</value>

42
MainForm.Designer.cs generated
View File

@@ -105,6 +105,11 @@
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.installTimer = new System.Windows.Forms.Timer(this.components); this.installTimer = new System.Windows.Forms.Timer(this.components);
this.mappingsContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
this.openMappingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveMappingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.openMapFileDialog = new System.Windows.Forms.OpenFileDialog();
this.saveMapFileDialog = new System.Windows.Forms.SaveFileDialog();
this.panel5.SuspendLayout(); this.panel5.SuspendLayout();
this.mainPanel.SuspendLayout(); this.mainPanel.SuspendLayout();
this.mainTabControl.SuspendLayout(); this.mainTabControl.SuspendLayout();
@@ -132,6 +137,7 @@
((System.ComponentModel.ISupportInitialize)(this.pictureBox7)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox7)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.trayIconContextMenuStrip.SuspendLayout(); this.trayIconContextMenuStrip.SuspendLayout();
this.mappingsContextMenuStrip.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// panel5 // panel5
@@ -680,6 +686,36 @@
// //
this.installTimer.Tick += new System.EventHandler(this.installTimer_Tick); this.installTimer.Tick += new System.EventHandler(this.installTimer_Tick);
// //
// mappingsContextMenuStrip
//
this.mappingsContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.openMappingsToolStripMenuItem,
this.saveMappingsToolStripMenuItem});
this.mappingsContextMenuStrip.Name = "mappingsContextMenuStrip";
resources.ApplyResources(this.mappingsContextMenuStrip, "mappingsContextMenuStrip");
//
// openMappingsToolStripMenuItem
//
this.openMappingsToolStripMenuItem.Name = "openMappingsToolStripMenuItem";
resources.ApplyResources(this.openMappingsToolStripMenuItem, "openMappingsToolStripMenuItem");
this.openMappingsToolStripMenuItem.Click += new System.EventHandler(this.openMappingsToolStripMenuItem_Click);
//
// saveMappingsToolStripMenuItem
//
this.saveMappingsToolStripMenuItem.Name = "saveMappingsToolStripMenuItem";
resources.ApplyResources(this.saveMappingsToolStripMenuItem, "saveMappingsToolStripMenuItem");
this.saveMappingsToolStripMenuItem.Click += new System.EventHandler(this.saveMappingsToolStripMenuItem_Click);
//
// openMapFileDialog
//
this.openMapFileDialog.DefaultExt = "mcrouter";
resources.ApplyResources(this.openMapFileDialog, "openMapFileDialog");
//
// saveMapFileDialog
//
this.saveMapFileDialog.DefaultExt = "mcrouter";
resources.ApplyResources(this.saveMapFileDialog, "saveMapFileDialog");
//
// MainForm // MainForm
// //
resources.ApplyResources(this, "$this"); resources.ApplyResources(this, "$this");
@@ -722,6 +758,7 @@
((System.ComponentModel.ISupportInitialize)(this.pictureBox7)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox7)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.trayIconContextMenuStrip.ResumeLayout(false); this.trayIconContextMenuStrip.ResumeLayout(false);
this.mappingsContextMenuStrip.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
} }
@@ -802,6 +839,11 @@
private System.Windows.Forms.Button smsTokenButton; private System.Windows.Forms.Button smsTokenButton;
private System.Windows.Forms.Button installButton; private System.Windows.Forms.Button installButton;
private System.Windows.Forms.Timer installTimer; private System.Windows.Forms.Timer installTimer;
private System.Windows.Forms.ContextMenuStrip mappingsContextMenuStrip;
private System.Windows.Forms.ToolStripMenuItem openMappingsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem saveMappingsToolStripMenuItem;
private System.Windows.Forms.OpenFileDialog openMapFileDialog;
private System.Windows.Forms.SaveFileDialog saveMapFileDialog;
} }
} }

View File

@@ -15,13 +15,16 @@ limitations under the License.
*/ */
using System; using System;
using System.IO;
using System.Net; using System.Net;
using System.Reflection; using System.Reflection;
using System.Collections; using System.Collections;
using System.Diagnostics; using System.Diagnostics;
using System.Windows.Forms; using System.Windows.Forms;
using System.Security.Principal; using System.Security.Principal;
using System.Collections.Generic;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Web.Script.Serialization;
using System.Security.Cryptography.X509Certificates; using System.Security.Cryptography.X509Certificates;
using Microsoft.Win32; using Microsoft.Win32;
@@ -44,6 +47,8 @@ namespace MeshCentralRouter
public bool sendSMSToken = false; public bool sendSMSToken = false;
public Uri authLoginUrl = null; public Uri authLoginUrl = null;
public Process installProcess = null; public Process installProcess = null;
public string acceptableCertHash = null;
public ArrayList mappingsToSetup = null;
public void setRegValue(string name, string value) { public void setRegValue(string name, string value) {
try { Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Open Source\MeshCentral Router", name, value); } catch (Exception) { } try { Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Open Source\MeshCentral Router", name, value); } catch (Exception) { }
@@ -177,6 +182,7 @@ namespace MeshCentralRouter
if (arg.Length > 6 && arg.Substring(0, 6).ToLower() == "-pass:") { passwordTextBox.Text = arg.Substring(6); argflags |= 4; } if (arg.Length > 6 && arg.Substring(0, 6).ToLower() == "-pass:") { passwordTextBox.Text = arg.Substring(6); argflags |= 4; }
if (arg.Length > 8 && arg.Substring(0, 8).ToLower() == "-search:") { searchTextBox.Text = arg.Substring(8); } if (arg.Length > 8 && arg.Substring(0, 8).ToLower() == "-search:") { searchTextBox.Text = arg.Substring(8); }
if (arg.Length > 11 && arg.Substring(0, 11).ToLower() == "mcrouter://") { authLoginUrl = new Uri(arg); } if (arg.Length > 11 && arg.Substring(0, 11).ToLower() == "mcrouter://") { authLoginUrl = new Uri(arg); }
if ((arg.Length > 1) && (arg[0] != '-') && (arg.ToLower().EndsWith(".mcrouter"))) { try { argflags |= loadMappingFile(File.ReadAllText(arg)); } catch (Exception) { } }
} }
autoLogin = (argflags == 7); autoLogin = (argflags == 7);
@@ -287,6 +293,7 @@ namespace MeshCentralRouter
meshcentral = new MeshCentralServer(); meshcentral = new MeshCentralServer();
meshcentral.debug = debug; meshcentral.debug = debug;
meshcentral.ignoreCert = ignoreCert; meshcentral.ignoreCert = ignoreCert;
if (acceptableCertHash != null) { meshcentral.okCertHash2 = acceptableCertHash; }
meshcentral.onStateChanged += Meshcentral_onStateChanged; meshcentral.onStateChanged += Meshcentral_onStateChanged;
meshcentral.onNodesChanged += Meshcentral_onNodesChanged; meshcentral.onNodesChanged += Meshcentral_onNodesChanged;
meshcentral.onLoginTokenChanged += Meshcentral_onLoginTokenChanged; meshcentral.onLoginTokenChanged += Meshcentral_onLoginTokenChanged;
@@ -336,9 +343,9 @@ namespace MeshCentralRouter
openWebSiteButton.Visible = true; openWebSiteButton.Visible = true;
} }
private void Meshcentral_onNodesChanged() private void Meshcentral_onNodesChanged(bool fullRefresh)
{ {
if (this.InvokeRequired) { this.Invoke(new MeshCentralServer.onNodeListChangedHandler(Meshcentral_onNodesChanged)); return; } if (this.InvokeRequired) { this.Invoke(new MeshCentralServer.onNodeListChangedHandler(Meshcentral_onNodesChanged), fullRefresh); return; }
addRelayButton.Enabled = addButton.Enabled = ((meshcentral.nodes != null) && (meshcentral.nodes.Count > 0)); addRelayButton.Enabled = addButton.Enabled = ((meshcentral.nodes != null) && (meshcentral.nodes.Count > 0));
// Update any active mappings // Update any active mappings
@@ -354,6 +361,9 @@ namespace MeshCentralRouter
updateDeviceList(); // Update list of devices updateDeviceList(); // Update list of devices
addArgMappings(); addArgMappings();
reconnectUdpMaps(); reconnectUdpMaps();
// Setup any automatic mappings
if ((fullRefresh == true) && (mappingsToSetup != null)) { setupMappings(); }
} }
private void updateDeviceList() private void updateDeviceList()
@@ -980,7 +990,12 @@ namespace MeshCentralRouter
private void devicesTabControl_SelectedIndexChanged(object sender, EventArgs e) private void devicesTabControl_SelectedIndexChanged(object sender, EventArgs e)
{ {
menuLabel.Visible = searchTextBox.Visible = (devicesTabControl.SelectedIndex == 0); searchTextBox.Visible = (devicesTabControl.SelectedIndex == 0);
if (devicesTabControl.SelectedIndex == 0) {
menuLabel.ContextMenuStrip = mainContextMenuStrip;
} else {
menuLabel.ContextMenuStrip = mappingsContextMenuStrip;
}
} }
private void searchTextBox_KeyPress(object sender, KeyPressEventArgs e) private void searchTextBox_KeyPress(object sender, KeyPressEventArgs e)
@@ -1057,7 +1072,14 @@ namespace MeshCentralRouter
private void menuLabel_Click(object sender, EventArgs e) private void menuLabel_Click(object sender, EventArgs e)
{ {
mainContextMenuStrip.Show(menuLabel, menuLabel.PointToClient(Cursor.Position)); if (devicesTabControl.SelectedIndex == 0)
{
mainContextMenuStrip.Show(menuLabel, menuLabel.PointToClient(Cursor.Position));
}
else
{
mappingsContextMenuStrip.Show(menuLabel, menuLabel.PointToClient(Cursor.Position));
}
} }
private void showGroupNamesToolStripMenuItem_Click(object sender, EventArgs e) private void showGroupNamesToolStripMenuItem_Click(object sender, EventArgs e)
@@ -1106,6 +1128,98 @@ namespace MeshCentralRouter
} }
} }
private void openMappingsToolStripMenuItem_Click(object sender, EventArgs e)
{
if (openMapFileDialog.ShowDialog(this) == DialogResult.OK)
{
string text = null;
try { text = File.ReadAllText(openMapFileDialog.FileName); } catch (Exception) { }
if (text != null) { loadMappingFile(text); }
}
}
private int loadMappingFile(string data)
{
int argFlags = 3;
Dictionary<string, object> jsonAction = new Dictionary<string, object>();
jsonAction = new JavaScriptSerializer().Deserialize<Dictionary<string, object>>(data);
if ((jsonAction == null) || (jsonAction["hostname"].GetType() != typeof(string)) || (jsonAction["username"].GetType() != typeof(string)) || (jsonAction["certhash"].GetType() != typeof(string))) return 0;
serverNameComboBox.Text = jsonAction["hostname"].ToString();
userNameTextBox.Text = jsonAction["username"].ToString();
if (jsonAction.ContainsKey("password")) { passwordTextBox.Text = jsonAction["password"].ToString(); argFlags |= 4; }
acceptableCertHash = jsonAction["certhash"].ToString();
if (jsonAction["mappings"] != null)
{
ArrayList mappings = (ArrayList)jsonAction["mappings"];
if (mappings.Count > 0) { mappingsToSetup = mappings; }
}
return argFlags;
}
private void setupMappings()
{
foreach (Dictionary<string, object> x in mappingsToSetup)
{
// Find the node
string nodeId = (string)x["nodeId"];
NodeClass node = meshcentral.nodes[nodeId];
if (node == null) continue;
// Add a new port map
MapUserControl map = new MapUserControl();
map.xdebug = debug;
map.inaddrany = inaddrany;
map.protocol = (int)x["protocol"];
map.localPort = (int)x["localPort"];
if (x.ContainsKey("remoteIP")) { map.remoteIP = (string)x["remoteIP"]; }
map.remotePort = (int)x["remotePort"];
map.appId = (int)x["appId"];
map.node = node;
if (authLoginUrl != null) { map.host = authLoginUrl.Host + ":" + ((authLoginUrl.Port > 0) ? authLoginUrl.Port : 443); } else { map.host = serverNameComboBox.Text; }
map.authCookie = meshcentral.authCookie;
map.certhash = meshcentral.wshash;
map.parent = this;
map.Dock = DockStyle.Top;
map.Start();
mapPanel.Controls.Add(map);
noMapLabel.Visible = false;
// Launch any executable
if (x.ContainsKey("launch")) { try { System.Diagnostics.Process.Start((string)x["launch"]); } catch (Exception) { } }
}
mappingsToSetup = null;
}
private void saveMappingsToolStripMenuItem_Click(object sender, EventArgs e)
{
if (saveMapFileDialog.ShowDialog(this) == DialogResult.OK)
{
string text = "{\r\n \"hostname\": \"" + serverNameComboBox.Text + "\",\r\n \"username\": \"" + userNameTextBox.Text + "\",\r\n \"certhash\": \"" + meshcentral.certHash + "\",\r\n \"mappings\":[\r\n";
var mapCounter = 0;
foreach (Control c in mapPanel.Controls)
{
if (c.GetType() != typeof(MapUserControl)) continue;
MapUserControl mapCtrl = (MapUserControl)c;
MeshMapper map = ((MapUserControl)c).mapper;
if (mapCounter == 0) { text += " {\r\n"; } else { text += ",\r\n {\r\n"; }
text += " \"nodeName\": \"" + mapCtrl.node.name + "\",\r\n";
text += " \"meshId\": \"" + mapCtrl.node.meshid + "\",\r\n";
text += " \"nodeId\": \"" + mapCtrl.node.nodeid + "\",\r\n";
text += " \"appId\": " + mapCtrl.appId + ",\r\n";
text += " \"protocol\": " + map.protocol + ",\r\n";
text += " \"localPort\": " + map.localport + ",\r\n";
if (map.remoteip != null) { text += " \"remoteIP\": \"" + map.remoteip + "\",\r\n"; }
text += " \"remotePort\": " + map.remoteport + "\r\n";
text += " }";
mapCounter++;
}
if (mapCounter > 0) { text += "\r\n ]\r\n}"; } else { text += " ]\r\n}"; }
File.WriteAllText(saveMapFileDialog.FileName, text);
}
}
/* /*
private delegate void displayMessageHandler(string msg, int buttons, string extra, int progress); private delegate void displayMessageHandler(string msg, int buttons, string extra, int progress);
private void displayMessage(string msg, int buttons = 0, string extra = "", int progress = 0) private void displayMessage(string msg, int buttons = 0, string extra = "", int progress = 0)

View File

@@ -1333,10 +1333,10 @@
<value>NoControl</value> <value>NoControl</value>
</data> </data>
<data name="noSearchResultsLabel.Location" type="System.Drawing.Point, System.Drawing"> <data name="noSearchResultsLabel.Location" type="System.Drawing.Point, System.Drawing">
<value>91, 96</value> <value>2, 88</value>
</data> </data>
<data name="noSearchResultsLabel.Size" type="System.Drawing.Size, System.Drawing"> <data name="noSearchResultsLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>243, 17</value> <value>462, 52</value>
</data> </data>
<data name="noSearchResultsLabel.TabIndex" type="System.Int32, mscorlib"> <data name="noSearchResultsLabel.TabIndex" type="System.Int32, mscorlib">
<value>5</value> <value>5</value>
@@ -1372,10 +1372,10 @@
<value>NoControl</value> <value>NoControl</value>
</data> </data>
<data name="noDevicesLabel.Location" type="System.Drawing.Point, System.Drawing"> <data name="noDevicesLabel.Location" type="System.Drawing.Point, System.Drawing">
<value>91, 97</value> <value>2, 88</value>
</data> </data>
<data name="noDevicesLabel.Size" type="System.Drawing.Size, System.Drawing"> <data name="noDevicesLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>243, 17</value> <value>462, 52</value>
</data> </data>
<data name="noDevicesLabel.TabIndex" type="System.Int32, mscorlib"> <data name="noDevicesLabel.TabIndex" type="System.Int32, mscorlib">
<value>4</value> <value>4</value>
@@ -1402,7 +1402,7 @@
<value>0, 0</value> <value>0, 0</value>
</data> </data>
<data name="devicesPanel.Size" type="System.Drawing.Size, System.Drawing"> <data name="devicesPanel.Size" type="System.Drawing.Size, System.Drawing">
<value>470, 244</value> <value>470, 250</value>
</data> </data>
<data name="devicesPanel.TabIndex" type="System.Int32, mscorlib"> <data name="devicesPanel.TabIndex" type="System.Int32, mscorlib">
<value>50</value> <value>50</value>
@@ -1426,7 +1426,7 @@
<value>3, 3, 3, 3</value> <value>3, 3, 3, 3</value>
</data> </data>
<data name="devicesTabPage.Size" type="System.Drawing.Size, System.Drawing"> <data name="devicesTabPage.Size" type="System.Drawing.Size, System.Drawing">
<value>470, 244</value> <value>470, 250</value>
</data> </data>
<data name="devicesTabPage.TabIndex" type="System.Int32, mscorlib"> <data name="devicesTabPage.TabIndex" type="System.Int32, mscorlib">
<value>0</value> <value>0</value>
@@ -1462,10 +1462,10 @@
<value>NoControl</value> <value>NoControl</value>
</data> </data>
<data name="noMapLabel.Location" type="System.Drawing.Point, System.Drawing"> <data name="noMapLabel.Location" type="System.Drawing.Point, System.Drawing">
<value>91, 79</value> <value>2, 79</value>
</data> </data>
<data name="noMapLabel.Size" type="System.Drawing.Size, System.Drawing"> <data name="noMapLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>243, 52</value> <value>462, 52</value>
</data> </data>
<data name="noMapLabel.TabIndex" type="System.Int32, mscorlib"> <data name="noMapLabel.TabIndex" type="System.Int32, mscorlib">
<value>4</value> <value>4</value>
@@ -1494,7 +1494,7 @@ Click "Add" to get started.</value>
<value>0, 0</value> <value>0, 0</value>
</data> </data>
<data name="mapPanel.Size" type="System.Drawing.Size, System.Drawing"> <data name="mapPanel.Size" type="System.Drawing.Size, System.Drawing">
<value>470, 214</value> <value>470, 220</value>
</data> </data>
<data name="mapPanel.TabIndex" type="System.Int32, mscorlib"> <data name="mapPanel.TabIndex" type="System.Int32, mscorlib">
<value>49</value> <value>49</value>
@@ -1518,7 +1518,7 @@ Click "Add" to get started.</value>
<value>NoControl</value> <value>NoControl</value>
</data> </data>
<data name="settingsPictureBox.Location" type="System.Drawing.Point, System.Drawing"> <data name="settingsPictureBox.Location" type="System.Drawing.Point, System.Drawing">
<value>1, 220</value> <value>1, 226</value>
</data> </data>
<data name="settingsPictureBox.Size" type="System.Drawing.Size, System.Drawing"> <data name="settingsPictureBox.Size" type="System.Drawing.Size, System.Drawing">
<value>20, 20</value> <value>20, 20</value>
@@ -1545,7 +1545,7 @@ Click "Add" to get started.</value>
<value>NoControl</value> <value>NoControl</value>
</data> </data>
<data name="helpPictureBox.Location" type="System.Drawing.Point, System.Drawing"> <data name="helpPictureBox.Location" type="System.Drawing.Point, System.Drawing">
<value>238, 220</value> <value>238, 226</value>
</data> </data>
<data name="helpPictureBox.Size" type="System.Drawing.Size, System.Drawing"> <data name="helpPictureBox.Size" type="System.Drawing.Size, System.Drawing">
<value>20, 20</value> <value>20, 20</value>
@@ -1575,7 +1575,7 @@ Click "Add" to get started.</value>
<value>NoControl</value> <value>NoControl</value>
</data> </data>
<data name="addButton.Location" type="System.Drawing.Point, System.Drawing"> <data name="addButton.Location" type="System.Drawing.Point, System.Drawing">
<value>370, 218</value> <value>370, 224</value>
</data> </data>
<data name="addButton.Size" type="System.Drawing.Size, System.Drawing"> <data name="addButton.Size" type="System.Drawing.Size, System.Drawing">
<value>100, 23</value> <value>100, 23</value>
@@ -1608,7 +1608,7 @@ Click "Add" to get started.</value>
<value>NoControl</value> <value>NoControl</value>
</data> </data>
<data name="addRelayButton.Location" type="System.Drawing.Point, System.Drawing"> <data name="addRelayButton.Location" type="System.Drawing.Point, System.Drawing">
<value>264, 218</value> <value>264, 224</value>
</data> </data>
<data name="addRelayButton.Size" type="System.Drawing.Size, System.Drawing"> <data name="addRelayButton.Size" type="System.Drawing.Size, System.Drawing">
<value>100, 23</value> <value>100, 23</value>
@@ -1638,7 +1638,7 @@ Click "Add" to get started.</value>
<value>3, 3, 3, 3</value> <value>3, 3, 3, 3</value>
</data> </data>
<data name="portMapTabPage.Size" type="System.Drawing.Size, System.Drawing"> <data name="portMapTabPage.Size" type="System.Drawing.Size, System.Drawing">
<value>470, 244</value> <value>470, 250</value>
</data> </data>
<data name="portMapTabPage.TabIndex" type="System.Int32, mscorlib"> <data name="portMapTabPage.TabIndex" type="System.Int32, mscorlib">
<value>1</value> <value>1</value>
@@ -1662,7 +1662,7 @@ Click "Add" to get started.</value>
<value>3, 3</value> <value>3, 3</value>
</data> </data>
<data name="devicesTabControl.Size" type="System.Drawing.Size, System.Drawing"> <data name="devicesTabControl.Size" type="System.Drawing.Size, System.Drawing">
<value>478, 273</value> <value>478, 279</value>
</data> </data>
<data name="devicesTabControl.TabIndex" type="System.Int32, mscorlib"> <data name="devicesTabControl.TabIndex" type="System.Int32, mscorlib">
<value>55</value> <value>55</value>
@@ -1953,7 +1953,7 @@ Click "Add" to get started.</value>
<value>$this</value> <value>$this</value>
</data> </data>
<data name="&gt;&gt;panel5.ZOrder" xml:space="preserve"> <data name="&gt;&gt;panel5.ZOrder" xml:space="preserve">
<value>2</value> <value>3</value>
</data> </data>
<metadata name="stateClearTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="stateClearTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value> <value>17, 17</value>
@@ -3691,6 +3691,48 @@ Click "Add" to get started.</value>
<metadata name="installTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="installTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>791, 17</value> <value>791, 17</value>
</metadata> </metadata>
<metadata name="mappingsContextMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>905, 17</value>
</metadata>
<data name="openMappingsToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>168, 22</value>
</data>
<data name="openMappingsToolStripMenuItem.Text" xml:space="preserve">
<value>&amp;Open Mappings...</value>
</data>
<data name="saveMappingsToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>168, 22</value>
</data>
<data name="saveMappingsToolStripMenuItem.Text" xml:space="preserve">
<value>&amp;Save Mappings...</value>
</data>
<data name="mappingsContextMenuStrip.Size" type="System.Drawing.Size, System.Drawing">
<value>169, 48</value>
</data>
<data name="&gt;&gt;mappingsContextMenuStrip.Name" xml:space="preserve">
<value>mappingsContextMenuStrip</value>
</data>
<data name="&gt;&gt;mappingsContextMenuStrip.Type" xml:space="preserve">
<value>System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<metadata name="openMapFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>1110, 17</value>
</metadata>
<data name="openMapFileDialog.Filter" xml:space="preserve">
<value>Router Mapping|*.mcrouter</value>
</data>
<data name="openMapFileDialog.Title" xml:space="preserve">
<value>Open Port Mappings</value>
</data>
<metadata name="saveMapFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>1268, 17</value>
</metadata>
<data name="saveMapFileDialog.Filter" xml:space="preserve">
<value>Router Mapping|*.mcrouter</value>
</data>
<data name="saveMapFileDialog.Title" xml:space="preserve">
<value>Save Port Mappings</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
@@ -5469,6 +5511,30 @@ Click "Add" to get started.</value>
<data name="&gt;&gt;installTimer.Type" xml:space="preserve"> <data name="&gt;&gt;installTimer.Type" xml:space="preserve">
<value>System.Windows.Forms.Timer, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Windows.Forms.Timer, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data> </data>
<data name="&gt;&gt;openMappingsToolStripMenuItem.Name" xml:space="preserve">
<value>openMappingsToolStripMenuItem</value>
</data>
<data name="&gt;&gt;openMappingsToolStripMenuItem.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;saveMappingsToolStripMenuItem.Name" xml:space="preserve">
<value>saveMappingsToolStripMenuItem</value>
</data>
<data name="&gt;&gt;saveMappingsToolStripMenuItem.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;openMapFileDialog.Name" xml:space="preserve">
<value>openMapFileDialog</value>
</data>
<data name="&gt;&gt;openMapFileDialog.Type" xml:space="preserve">
<value>System.Windows.Forms.OpenFileDialog, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;saveMapFileDialog.Name" xml:space="preserve">
<value>saveMapFileDialog</value>
</data>
<data name="&gt;&gt;saveMapFileDialog.Type" xml:space="preserve">
<value>System.Windows.Forms.SaveFileDialog, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve"> <data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>MainForm</value> <value>MainForm</value>
</data> </data>

View File

@@ -147,11 +147,14 @@
<data name="deviceNameLabel.Font" type="System.Drawing.Font, System.Drawing"> <data name="deviceNameLabel.Font" type="System.Drawing.Font, System.Drawing">
<value>Microsoft Sans Serif, 8.25pt, style=Bold</value> <value>Microsoft Sans Serif, 8.25pt, style=Bold</value>
</data> </data>
<data name="deviceNameLabel.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="deviceNameLabel.Location" type="System.Drawing.Point, System.Drawing"> <data name="deviceNameLabel.Location" type="System.Drawing.Point, System.Drawing">
<value>62, 12</value> <value>62, 12</value>
</data> </data>
<data name="deviceNameLabel.Size" type="System.Drawing.Size, System.Drawing"> <data name="deviceNameLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>290, 15</value> <value>294, 15</value>
</data> </data>
<data name="deviceNameLabel.TabIndex" type="System.Int32, mscorlib"> <data name="deviceNameLabel.TabIndex" type="System.Int32, mscorlib">
<value>1</value> <value>1</value>
@@ -174,11 +177,14 @@
<data name="routingStatusLabel.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms"> <data name="routingStatusLabel.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Left, Right</value> <value>Top, Left, Right</value>
</data> </data>
<data name="routingStatusLabel.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="routingStatusLabel.Location" type="System.Drawing.Point, System.Drawing"> <data name="routingStatusLabel.Location" type="System.Drawing.Point, System.Drawing">
<value>62, 32</value> <value>62, 32</value>
</data> </data>
<data name="routingStatusLabel.Size" type="System.Drawing.Size, System.Drawing"> <data name="routingStatusLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>290, 15</value> <value>294, 15</value>
</data> </data>
<data name="routingStatusLabel.TabIndex" type="System.Int32, mscorlib"> <data name="routingStatusLabel.TabIndex" type="System.Int32, mscorlib">
<value>2</value> <value>2</value>
@@ -202,7 +208,7 @@
<value>Top, Right</value> <value>Top, Right</value>
</data> </data>
<data name="appButton.Location" type="System.Drawing.Point, System.Drawing"> <data name="appButton.Location" type="System.Drawing.Point, System.Drawing">
<value>358, 6</value> <value>348, 6</value>
</data> </data>
<data name="appButton.Size" type="System.Drawing.Size, System.Drawing"> <data name="appButton.Size" type="System.Drawing.Size, System.Drawing">
<value>75, 23</value> <value>75, 23</value>
@@ -229,7 +235,7 @@
<value>Top, Right</value> <value>Top, Right</value>
</data> </data>
<data name="closeButton.Location" type="System.Drawing.Point, System.Drawing"> <data name="closeButton.Location" type="System.Drawing.Point, System.Drawing">
<value>358, 30</value> <value>348, 30</value>
</data> </data>
<data name="closeButton.Size" type="System.Drawing.Size, System.Drawing"> <data name="closeButton.Size" type="System.Drawing.Size, System.Drawing">
<value>75, 23</value> <value>75, 23</value>
@@ -260,7 +266,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAy ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAy
mgAAAk1TRnQBSQFMAgEBCAEAATgBAAE4AQABMgEAATIBAAT/AREBAAj/AUIBTQE2BwABNgMAASgDAAHI mgAAAk1TRnQBSQFMAgEBCAEAAUABAAFAAQABMgEAATIBAAT/AREBAAj/AUIBTQE2BwABNgMAASgDAAHI
AwABlgMAAQEBAAEQBQABYAHq/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A AwABlgMAAQEBAAEQBQABYAHq/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A
/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A /wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A
/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A /wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A
@@ -927,7 +933,7 @@
<value>6, 13</value> <value>6, 13</value>
</data> </data>
<data name="$this.Size" type="System.Drawing.Size, System.Drawing"> <data name="$this.Size" type="System.Drawing.Size, System.Drawing">
<value>433, 52</value> <value>433, 60</value>
</data> </data>
<data name="&gt;&gt;deviceImageList.Name" xml:space="preserve"> <data name="&gt;&gt;deviceImageList.Name" xml:space="preserve">
<value>deviceImageList</value> <value>deviceImageList</value>

View File

@@ -54,6 +54,7 @@ namespace MeshCentralRouter
public string authCookie = null; public string authCookie = null;
public string loginCookie = null; public string loginCookie = null;
public string wshash = null; public string wshash = null;
public string certHash = null;
public string okCertHash = null; public string okCertHash = null;
public string okCertHash2 = null; public string okCertHash2 = null;
public bool debug = false; public bool debug = false;
@@ -141,7 +142,7 @@ namespace MeshCentralRouter
wc = new xwebclient(); wc = new xwebclient();
//Debug("#" + counter + ": Connecting web socket to: " + wsurl.ToString()); //Debug("#" + counter + ": Connecting web socket to: " + wsurl.ToString());
wc.Start(this, wsurl, user, pass, token, wshash); wc.Start(this, wsurl, user, pass, token, wshash);
if (debug) { File.AppendAllText("debug.log", "Connect-" + wsurl + "\r\n"); } if (debug) { try { File.AppendAllText("debug.log", "Connect-" + wsurl + "\r\n"); } catch (Exception) { } }
wc.xdebug = debug; wc.xdebug = debug;
wc.xignoreCert = ignoreCert; wc.xignoreCert = ignoreCert;
} }
@@ -152,14 +153,14 @@ namespace MeshCentralRouter
{ {
wc.Dispose(); wc.Dispose();
wc = null; wc = null;
if (debug) { File.AppendAllText("debug.log", "Disconnect\r\n"); } if (debug) { try { File.AppendAllText("debug.log", "Disconnect\r\n"); } catch (Exception) { } }
} }
} }
public void refreshCookies() public void refreshCookies()
{ {
if (wc != null) { if (wc != null) {
if (debug) { File.AppendAllText("debug.log", "RefreshCookies\r\n"); } if (debug) { try { File.AppendAllText("debug.log", "RefreshCookies\r\n"); } catch (Exception) { } }
wc.WriteStringWebSocket("{\"action\":\"authcookie\"}"); wc.WriteStringWebSocket("{\"action\":\"authcookie\"}");
wc.WriteStringWebSocket("{\"action\":\"logincookie\"}"); wc.WriteStringWebSocket("{\"action\":\"logincookie\"}");
} }
@@ -169,14 +170,14 @@ namespace MeshCentralRouter
{ {
if (wc != null) if (wc != null)
{ {
if (debug) { File.AppendAllText("debug.log", "SetRdpPort\r\n"); } if (debug) { try { File.AppendAllText("debug.log", "SetRdpPort\r\n"); } catch (Exception) { } }
wc.WriteStringWebSocket("{\"action\":\"changedevice\",\"nodeid\":\"" + node.nodeid + "\",\"rdpport\":" + port + "}"); wc.WriteStringWebSocket("{\"action\":\"changedevice\",\"nodeid\":\"" + node.nodeid + "\",\"rdpport\":" + port + "}");
} }
} }
public void processServerData(string data) public void processServerData(string data)
{ {
if (debug) { File.AppendAllText("debug.log", "ServerData-" + data + "\r\n"); } if (debug) { try { File.AppendAllText("debug.log", "ServerData-" + data + "\r\n"); } catch (Exception) { } }
// Parse the received JSON // Parse the received JSON
Dictionary<string, object> jsonAction = new Dictionary<string, object>(); Dictionary<string, object> jsonAction = new Dictionary<string, object>();
@@ -253,7 +254,7 @@ namespace MeshCentralRouter
userGroups.Add(i, usergroupsEx["name"].ToString()); userGroups.Add(i, usergroupsEx["name"].ToString());
} }
} }
if ((onNodesChanged != null) && (nodes != null)) onNodesChanged(); if ((onNodesChanged != null) && (nodes != null)) onNodesChanged(false);
} }
} }
break; break;
@@ -314,7 +315,7 @@ namespace MeshCentralRouter
meshes[meshid] = mesh; meshes[meshid] = mesh;
} }
wc.WriteStringWebSocket("{\"action\":\"nodes\"}"); wc.WriteStringWebSocket("{\"action\":\"nodes\"}");
if ((onNodesChanged != null) && (nodes != null)) onNodesChanged(); if ((onNodesChanged != null) && (nodes != null)) onNodesChanged(false);
break; break;
} }
case "changenode": case "changenode":
@@ -366,7 +367,7 @@ namespace MeshCentralRouter
nodes[n.nodeid] = n; nodes[n.nodeid] = n;
} }
} }
if ((onNodesChanged != null) && (nodes != null)) onNodesChanged(); if ((onNodesChanged != null) && (nodes != null)) onNodesChanged(false);
} }
else else
{ {
@@ -385,7 +386,7 @@ namespace MeshCentralRouter
if (ev.ContainsKey("conn")) { n.conn = (int)ev["conn"]; } if (ev.ContainsKey("conn")) { n.conn = (int)ev["conn"]; }
nodes[n.nodeid] = n; nodes[n.nodeid] = n;
} }
if ((onNodesChanged != null) && (nodes != null)) onNodesChanged(); if ((onNodesChanged != null) && (nodes != null)) onNodesChanged(false);
} }
break; break;
} }
@@ -521,7 +522,7 @@ namespace MeshCentralRouter
} }
} }
nodes = nodes2; nodes = nodes2;
if ((onNodesChanged != null) && (nodes != null)) onNodesChanged(); if ((onNodesChanged != null) && (nodes != null)) onNodesChanged(true);
break; break;
} }
default: default:
@@ -535,7 +536,7 @@ namespace MeshCentralRouter
public event onStateChangedHandler onStateChanged; public event onStateChangedHandler onStateChanged;
public void changeState(int newState) { if (constate != newState) { constate = newState; if (onStateChanged != null) { onStateChanged(constate); } } } public void changeState(int newState) { if (constate != newState) { constate = newState; if (onStateChanged != null) { onStateChanged(constate); } } }
public delegate void onNodeListChangedHandler(); public delegate void onNodeListChangedHandler(bool fullRefresh);
public event onNodeListChangedHandler onNodesChanged; public event onNodeListChangedHandler onNodesChanged;
public delegate void onLoginTokenChangedHandler(); public delegate void onLoginTokenChangedHandler();
public event onLoginTokenChangedHandler onLoginTokenChanged; public event onLoginTokenChangedHandler onLoginTokenChanged;
@@ -900,6 +901,7 @@ namespace MeshCentralRouter
private bool VerifyServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) private bool VerifyServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{ {
parent.certHash = GetMeshKeyHash(certificate);
if (xignoreCert) return true; if (xignoreCert) return true;
if (chain.Build(new X509Certificate2(certificate)) == true) return true; if (chain.Build(new X509Certificate2(certificate)) == true) return true;
@@ -909,6 +911,7 @@ namespace MeshCentralRouter
// Check that the remote certificate is the expected one // Check that the remote certificate is the expected one
if ((parent.okCertHash2 != null) && ((parent.okCertHash2 == GetMeshKeyHash(certificate)) || (parent.okCertHash2 == GetMeshCertHash(certificate)))) { return true; } if ((parent.okCertHash2 != null) && ((parent.okCertHash2 == GetMeshKeyHash(certificate)) || (parent.okCertHash2 == GetMeshCertHash(certificate)))) { return true; }
parent.certHash = null;
parent.disconnectMsg = "cert"; parent.disconnectMsg = "cert";
parent.disconnectCert = new X509Certificate2(certificate); parent.disconnectCert = new X509Certificate2(certificate);
return false; return false;