mirror of
https://github.com/Ylianst/MeshCentralRouter
synced 2025-12-06 00:13:33 +00:00
Compare commits
4 Commits
ae2ec2f30e
...
6c36e37caa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6c36e37caa | ||
|
|
e98f76a6d7 | ||
|
|
a99a01dca6 | ||
|
|
1f9c7fa8af |
@@ -46,6 +46,7 @@ namespace MeshCentralRouter
|
||||
private FileDialogMsgForm msgForm = null;
|
||||
private bool localSortAscending = true;
|
||||
private bool remoteSortAscending = true;
|
||||
private const int DirectoryNameCharacterLimit = 10;
|
||||
|
||||
// Stats
|
||||
public long bytesIn = 0;
|
||||
@@ -118,7 +119,9 @@ namespace MeshCentralRouter
|
||||
string[] parts = localFolder.FullName.Split(Path.DirectorySeparatorChar);
|
||||
for (int i = 0; i < parts.Length; i++)
|
||||
{
|
||||
ToolStripButton dirButton = new ToolStripButton(parts[i]);
|
||||
string displayText = parts[i].Length > DirectoryNameCharacterLimit ?
|
||||
parts[i].Substring(0, DirectoryNameCharacterLimit) + "..." : parts[i];
|
||||
ToolStripButton dirButton = new ToolStripButton(displayText);
|
||||
int index = i; // Local copy for the lambda
|
||||
dirButton.Click += (sender, e) => LocalPathButtonClicked(parts.Take(index + 1).ToArray());
|
||||
localDirectoryPath.Items.Add(dirButton);
|
||||
@@ -145,7 +148,9 @@ namespace MeshCentralRouter
|
||||
string[] parts = remoteFolder.Split(new char[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
for (int i = 0; i < parts.Length; i++)
|
||||
{
|
||||
ToolStripButton dirButton = new ToolStripButton(parts[i]);
|
||||
string displayText = parts[i].Length > DirectoryNameCharacterLimit ?
|
||||
parts[i].Substring(0, DirectoryNameCharacterLimit) + "..." : parts[i];
|
||||
ToolStripButton dirButton = new ToolStripButton(displayText);
|
||||
int index = i; // Local copy for the lambda
|
||||
dirButton.Click += (sender, e) => RemotePathButtonClicked(parts.Take(index + 1).ToArray());
|
||||
remoteDirectoryPath.Items.Add(dirButton);
|
||||
@@ -158,7 +163,6 @@ namespace MeshCentralRouter
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void LocalPathButtonClicked(string[] parts)
|
||||
{
|
||||
string path = string.Join(Path.DirectorySeparatorChar.ToString(), parts);
|
||||
@@ -181,7 +185,6 @@ namespace MeshCentralRouter
|
||||
requestRemoteFolder(path); // This will also call UpdateRemotePathDisplay
|
||||
}
|
||||
|
||||
|
||||
private void LeftListView_ColumnClick(object sender, ColumnClickEventArgs e)
|
||||
{
|
||||
if (localFolder == null) return;
|
||||
|
||||
@@ -1745,7 +1745,7 @@ namespace MeshCentralRouter
|
||||
public void QuickMap(int protocol, int port, int appId, NodeClass node)
|
||||
{
|
||||
NodeClass tmpNode = node;
|
||||
if (node.mesh.relayid != null)
|
||||
if (node.mesh != null && node.mesh.relayid != null)
|
||||
{
|
||||
if (!meshcentral.nodes.ContainsKey(node.mesh.relayid))
|
||||
return;
|
||||
@@ -1759,7 +1759,8 @@ namespace MeshCentralRouter
|
||||
if (c.GetType() == typeof(MapUserControl))
|
||||
{
|
||||
MapUserControl cc = (MapUserControl)c;
|
||||
if ((cc.remoteIP == node.host) && (cc.protocol == protocol) && (cc.remotePort == port) && (cc.appId == appId) && (cc.node == tmpNode))
|
||||
if ((cc.protocol == protocol) && (cc.remotePort == port) && (cc.appId == appId) &&
|
||||
(cc.node == tmpNode || cc.node == node) && (tmpNode == node || cc.remoteIP == node.host))
|
||||
{
|
||||
// Found a match
|
||||
cc.appButton_Click(this, null);
|
||||
@@ -1773,7 +1774,7 @@ namespace MeshCentralRouter
|
||||
map.xdebug = debug;
|
||||
map.inaddrany = false; // Loopback only
|
||||
map.protocol = protocol; // 1 = TCP, 2 = UDP
|
||||
if (node.mesh.relayid != null)
|
||||
if (node.mesh != null && node.mesh.relayid != null)
|
||||
{
|
||||
map.name = node.name;
|
||||
map.remoteIP = node.host;
|
||||
@@ -1794,43 +1795,6 @@ namespace MeshCentralRouter
|
||||
map.appButton_Click(this, null);
|
||||
}
|
||||
|
||||
public void QuickMap(int protocol, int port, string appIdStr, NodeClass node)
|
||||
{
|
||||
// See if we already have the right port mapping
|
||||
foreach (Control c in mapPanel.Controls)
|
||||
{
|
||||
if (c.GetType() == typeof(MapUserControl))
|
||||
{
|
||||
MapUserControl cc = (MapUserControl)c;
|
||||
if ((cc.protocol == protocol) && (cc.remotePort == port) && (cc.appIdStr == appIdStr) && (cc.node == node))
|
||||
{
|
||||
// Found a match
|
||||
cc.appButton_Click(this, null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add a new port map
|
||||
MapUserControl map = new MapUserControl();
|
||||
map.xdebug = debug;
|
||||
map.inaddrany = false; // Loopback only
|
||||
map.protocol = protocol; // 1 = TCP, 2 = UDP
|
||||
map.localPort = 0; // Any
|
||||
map.remotePort = port; // HTTP
|
||||
map.appId = 0; // 0 = Custom, 1 = HTTP, 2 = HTTPS, 3 = RDP, 4 = PuTTY, 5 = WinSCP
|
||||
map.appIdStr = appIdStr;
|
||||
map.node = node;
|
||||
if (authLoginUrl != null) { map.host = authLoginUrl.Host + ":" + ((authLoginUrl.Port > 0) ? authLoginUrl.Port : 443) + authLoginUrl.AbsolutePath.Replace("/control.ashx", ""); } else { map.host = serverNameComboBox.Text; }
|
||||
map.certhash = meshcentral.wshash;
|
||||
map.parent = this;
|
||||
map.Dock = DockStyle.Top;
|
||||
map.Start();
|
||||
mapPanel.Controls.Add(map);
|
||||
noMapLabel.Visible = false;
|
||||
map.appButton_Click(this, null);
|
||||
}
|
||||
|
||||
private void emailTokenButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (MessageBox.Show(this, Translate.T(Properties.Resources.SendTokenEmail), Translate.T(Properties.Resources.TwoFactorAuthentication), MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
|
||||
@@ -2007,6 +1971,31 @@ namespace MeshCentralRouter
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// See if we already have the right port mapping
|
||||
NodeClass tmpNode = node;
|
||||
if (node.mesh != null && node.mesh.relayid != null)
|
||||
{
|
||||
if (!meshcentral.nodes.ContainsKey(node.mesh.relayid))
|
||||
return;
|
||||
|
||||
tmpNode = meshcentral.nodes[node.mesh.relayid];
|
||||
}
|
||||
foreach (Control c in mapPanel.Controls)
|
||||
{
|
||||
if (c.GetType() == typeof(MapUserControl))
|
||||
{
|
||||
MapUserControl cc = (MapUserControl)c;
|
||||
if ((cc.protocol == (int)x["protocol"]) && (cc.remotePort == (int)x["remotePort"]) && (cc.appId == appId) &&
|
||||
(cc.node == tmpNode || cc.node == node) && (tmpNode == node || cc.remoteIP == node.host))
|
||||
{
|
||||
// Found a match
|
||||
cc.appButton_Click(this, null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add a new port map
|
||||
MapUserControl map = new MapUserControl();
|
||||
map.xdebug = debug;
|
||||
|
||||
Reference in New Issue
Block a user