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

Added local device group support.

This commit is contained in:
Ylian Saint-Hilaire
2021-04-28 00:45:17 -07:00
parent 1a8dd93886
commit d64fd051e8
7 changed files with 46 additions and 18 deletions

View File

@@ -40,13 +40,13 @@ namespace MeshCentralRouter
foreach (string meshid in meshcentral.meshes.Keys)
{
MeshClass mesh = meshcentral.meshes[meshid];
if (mesh.type == 2)
if ((mesh.type == 2) || (mesh.type == 3))
{
int nodeCount = 0;
foreach (string nodeid in meshcentral.nodes.Keys)
{
NodeClass node = meshcentral.nodes[nodeid];
if ((node.meshid == mesh.meshid) && ((node.conn & 1) != 0)) { nodeCount++; }
if ((node.meshid == mesh.meshid) && (((node.conn & 1) != 0) || (node.mtype == 3))) { nodeCount++; }
}
if (nodeCount > 0) { groupComboBox.Items.Add(mesh); }
}
@@ -103,7 +103,7 @@ namespace MeshCentralRouter
foreach (string nodeid in meshcentral.nodes.Keys)
{
NodeClass node = meshcentral.nodes[nodeid];
if (((node.meshid == mesh.meshid) || ((mesh.meshid == null) && (meshcentral.userRights.ContainsKey(node.nodeid)))) && ((node.conn & 1) != 0)) { nodeComboBox.Items.Add(node); }
if (((node.meshid == mesh.meshid) || ((mesh.meshid == null) && (meshcentral.userRights.ContainsKey(node.nodeid)))) && (((node.conn & 1) != 0) || (node.mtype == 3))) { nodeComboBox.Items.Add(node); }
}
}

View File

@@ -620,9 +620,9 @@ namespace MeshCentralRouter
device.SubItems[0].Text = node.name;
}
bool connVisible = ((showOfflineDevicesToolStripMenuItem.Checked) || ((node.conn & 1) != 0));
bool connVisible = ((showOfflineDevicesToolStripMenuItem.Checked) || ((node.conn & 1) != 0)) || (node.mtype == 3);
int imageIndex = (node.icon - 1) * 2;
if ((node.conn & 1) == 0) { imageIndex++; }
if (((node.conn & 1) == 0) && (node.mtype != 3)) { imageIndex++; }
device.ImageIndex = imageIndex;
string userSearch = null;
@@ -1094,7 +1094,7 @@ namespace MeshCentralRouter
if (devicesListView.SelectedItems.Count != 1) { return; }
ListViewItem selecteditem = devicesListView.SelectedItems[0];
NodeClass node = (NodeClass)selecteditem.Tag;
if ((node.conn & 1) == 0) { return; } // Agent not connected on this device
if (((node.conn & 1) == 0) && (node.mtype != 3)) { return; } // Agent not connected on this device & not local device
form.setNode(node);
}
@@ -1654,7 +1654,7 @@ namespace MeshCentralRouter
if (devicesListView.SelectedItems.Count != 1) { e.Cancel = true; return; } // Device not selected
ListViewItem selecteditem = devicesListView.SelectedItems[0];
NodeClass node = (NodeClass)selecteditem.Tag;
if ((node.conn & 1) == 0) { e.Cancel = true; return; } // Agent not connected on this device
if (((node.conn & 1) == 0) && (node.mtype != 3)) { e.Cancel = true; return; } // Agent not connected on this device
if (node.agentid < 6)
{
// Windows OS
@@ -1669,7 +1669,9 @@ namespace MeshCentralRouter
scpToolStripMenuItem.Visible = true;
rdpToolStripMenuItem.Visible = false;
}
remoteDesktopToolStripMenuItem.Visible = ((node.agentcaps & 1) != 0); // Only display remote desktop if it's supported by the agent
addRelayMapToolStripMenuItem.Visible = (node.mtype != 3); // Relay mappings are not allowed for local devices
remoteDesktopToolStripMenuItem.Visible = ((node.agentcaps & 1) != 0); // Only display remote desktop if it's supported by the agent (1 = Desktop)
remoteFilesToolStripMenuItem.Visible = ((node.agentcaps & 4) != 0); // Only display remote desktop if it's supported by the agent (4 = Files)
}
private void httpToolStripMenuItem_Click(object sender, EventArgs e)
@@ -1677,7 +1679,7 @@ namespace MeshCentralRouter
if (devicesListView.SelectedItems.Count != 1) { return; }
ListViewItem selecteditem = devicesListView.SelectedItems[0];
NodeClass node = (NodeClass)selecteditem.Tag;
if ((node.conn & 1) == 0) { return; } // Agent not connected on this device
if (((node.conn & 1) == 0) && (node.mtype != 3)) { return; } // Agent not connected on this device & not local device
QuickMap(1, 80, 1, node); // HTTP
}
@@ -1686,7 +1688,7 @@ namespace MeshCentralRouter
if (devicesListView.SelectedItems.Count != 1) { return; }
ListViewItem selecteditem = devicesListView.SelectedItems[0];
NodeClass node = (NodeClass)selecteditem.Tag;
if ((node.conn & 1) == 0) { return; } // Agent not connected on this device
if (((node.conn & 1) == 0) && (node.mtype != 3)) { return; } // Agent not connected on this device & not local device
QuickMap(1, 443, 2, node); // HTTPS
}
private void rdpToolStripMenuItem_Click(object sender, EventArgs e)
@@ -1694,7 +1696,7 @@ namespace MeshCentralRouter
if (devicesListView.SelectedItems.Count != 1) { return; }
ListViewItem selecteditem = devicesListView.SelectedItems[0];
NodeClass node = (NodeClass)selecteditem.Tag;
if ((node.conn & 1) == 0) { return; } // Agent not connected on this device
if (((node.conn & 1) == 0) && (node.mtype != 3)) { return; } // Agent not connected on this device & not local device
int rdpport = 3389;
if (node.rdpport != 0) { rdpport = node.rdpport; }
QuickMap(1, rdpport, 3, node); // RDP
@@ -1705,7 +1707,7 @@ namespace MeshCentralRouter
if (devicesListView.SelectedItems.Count != 1) { return; }
ListViewItem selecteditem = devicesListView.SelectedItems[0];
NodeClass node = (NodeClass)selecteditem.Tag;
if ((node.conn & 1) == 0) { return; } // Agent not connected on this device
if (((node.conn & 1) == 0) && (node.mtype != 3)) { return; } // Agent not connected on this device & not local device
QuickMap(1, 22, 4, node); // Putty
}
@@ -1714,7 +1716,7 @@ namespace MeshCentralRouter
if (devicesListView.SelectedItems.Count != 1) { return; }
ListViewItem selecteditem = devicesListView.SelectedItems[0];
NodeClass node = (NodeClass)selecteditem.Tag;
if ((node.conn & 1) == 0) { return; } // Agent not connected on this device
if (((node.conn & 1) == 0) && (node.mtype != 3)) { return; } // Agent not connected on this device & not local device
QuickMap(1, 22, 5, node); // WinSCP
}
@@ -1723,7 +1725,7 @@ namespace MeshCentralRouter
if (devicesListView.SelectedItems.Count != 1) { return; }
ListViewItem selecteditem = devicesListView.SelectedItems[0];
NodeClass node = (NodeClass)selecteditem.Tag;
if ((node.conn & 1) == 0) { return; } // Agent not connected on this device
if (((node.conn & 1) == 0) && (node.mtype != 3)) { return; } // Agent not connected on this device & not local device
addButton_Click(null, null);
}
@@ -1732,7 +1734,7 @@ namespace MeshCentralRouter
if (devicesListView.SelectedItems.Count != 1) { return; }
ListViewItem selecteditem = devicesListView.SelectedItems[0];
NodeClass node = (NodeClass)selecteditem.Tag;
if ((node.conn & 1) == 0) { return; } // Agent not connected on this device
if (((node.conn & 1) == 0) && (node.mtype != 3)) { return; } // Agent not connected on this device & not local device
addRelayMapButton_Click(null, null);
}
@@ -1742,7 +1744,7 @@ namespace MeshCentralRouter
if (devicesListView.SelectedItems.Count != 1) { return; }
ListViewItem selecteditem = devicesListView.SelectedItems[0];
NodeClass node = (NodeClass)selecteditem.Tag;
if ((node.conn & 1) == 0) { return; } // Agent not connected on this device
if (((node.conn & 1) == 0) && (node.mtype != 3)) { return; } // Agent not connected on this device & not local device
if (deviceDoubleClickAction == 0) { addMapToolStripMenuItem_Click(null, null); }
if (deviceDoubleClickAction == 1) { addRelayMapToolStripMenuItem_Click(null, null); }

View File

@@ -70,9 +70,9 @@ namespace MeshCentralRouter
string serverurl;
int keyIndex = host.IndexOf("?key=");
if (keyIndex >= 0) {
serverurl = "wss://" + host.Substring(0, keyIndex) + "/meshrelay.ashx?nodeid=" + node.nodeid + "&key=" + host.Substring(keyIndex + 5);
serverurl = "wss://" + host.Substring(0, keyIndex) + "/" + ((node.mtype == 3)?"local":"mesh") + "relay.ashx?nodeid=" + node.nodeid + "&key=" + host.Substring(keyIndex + 5);
} else {
serverurl = "wss://" + host + "/meshrelay.ashx?nodeid=" + node.nodeid;
serverurl = "wss://" + host + "/" + ((node.mtype == 3) ? "local" : "mesh") + "relay.ashx?nodeid=" + node.nodeid;
}
if (protocol == 1) {
serverurl += ("&tcpport=" + remotePort);

View File

@@ -492,10 +492,16 @@ namespace MeshCentralRouter
}
n.name = (string)node["name"];
n.meshid = meshid;
if (node.ContainsKey("mtype"))
{
if (node["mtype"].GetType() == typeof(string)) { n.mtype = int.Parse((string)node["mtype"]); }
if (node["mtype"].GetType() == typeof(int)) { n.mtype = (int)node["mtype"]; }
}
if (node.ContainsKey("users")) { n.users = (string[])((ArrayList)node["users"]).ToArray(typeof(string)); } else { n.users = null; }
if (node.ContainsKey("rdpport")) { n.rdpport = (int)node["rdpport"]; } else { n.rdpport = 3389; }
if (node.ContainsKey("conn")) { n.conn = (int)node["conn"]; } else { n.conn = 0; }
if (node.ContainsKey("icon")) { n.icon = (int)node["icon"]; }
if (n.icon == 0) { n.icon = 1; }
n.rights = 0;
n.links = new Dictionary<string, ulong>();
if (node.ContainsKey("links"))
@@ -531,10 +537,16 @@ namespace MeshCentralRouter
n.name = (string)node["name"];
n.meshid = meshid;
if (node.ContainsKey("mtype"))
{
if (node["mtype"].GetType() == typeof(string)) { n.mtype = int.Parse((string)node["mtype"]); }
if (node["mtype"].GetType() == typeof(int)) { n.mtype = (int)node["mtype"]; }
}
if (node.ContainsKey("users")) { n.users = (string[])((ArrayList)node["users"]).ToArray(typeof(string)); } else { n.users = null; }
if (node.ContainsKey("rdpport")) { n.rdpport = (int)node["rdpport"]; } else { n.rdpport = 3389; }
if (node.ContainsKey("conn")) { n.conn = (int)node["conn"]; } else { n.conn = 0; }
if (node.ContainsKey("icon")) { n.icon = (int)node["icon"]; }
if (n.icon == 0) { n.icon = 1; }
n.rights = 0;
n.links = new Dictionary<string, ulong>();
if (node.ContainsKey("links"))

View File

@@ -18,6 +18,7 @@ namespace MeshCentralRouter
public int conn;
public int rdpport;
public ulong rights;
public int mtype;
public MeshClass mesh;
public ListViewItem listitem;
public DeviceUserControl control;
@@ -31,6 +32,7 @@ namespace MeshCentralRouter
public string getStateString()
{
string status = "";
if (mtype == 3) return Properties.Resources.Local;
if ((conn & 1) != 0) { if (status.Length > 0) { status += ", "; } status += Properties.Resources.Agent; }
if ((conn & 2) != 0) { if (status.Length > 0) { status += ", "; } status += Properties.Resources.CIRA; }
if ((conn & 4) != 0) { if (status.Length > 0) { status += ", "; } status += Properties.Resources.AMT; }

View File

@@ -300,6 +300,15 @@ namespace MeshCentralRouter.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Local.
/// </summary>
internal static string Local {
get {
return ResourceManager.GetString("Local", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to , {0} connections..
/// </summary>

View File

@@ -268,4 +268,7 @@
<data name="OpenSSHAppName" xml:space="preserve">
<value>OpenSSH</value>
</data>
<data name="Local" xml:space="preserve">
<value>Local</value>
</data>
</root>