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

Added launching built-in desktop/files from URL link.

This commit is contained in:
Ylian Saint-Hilaire
2021-05-21 09:48:25 -07:00
parent 53c92b48c3
commit b418493e95

View File

@@ -227,15 +227,15 @@ namespace MeshCentralRouter
// Automatic mappings // Automatic mappings
autoNodeId = getValueFromQueryString(authLoginUrl.Query, "nodeid"); autoNodeId = getValueFromQueryString(authLoginUrl.Query, "nodeid");
autoRemoteIp = getValueFromQueryString(authLoginUrl.Query, "remoteip"); autoRemoteIp = getValueFromQueryString(authLoginUrl.Query, "remoteip");
autoRemotePort = int.Parse(getValueFromQueryString(authLoginUrl.Query, "remoteport")); int.TryParse(getValueFromQueryString(authLoginUrl.Query, "remoteport"), out autoRemotePort);
autoProtocol = int.Parse(getValueFromQueryString(authLoginUrl.Query, "protocol")); int.TryParse(getValueFromQueryString(authLoginUrl.Query, "protocol"), out autoProtocol);
autoAppId = int.Parse(getValueFromQueryString(authLoginUrl.Query, "appid")); int.TryParse(getValueFromQueryString(authLoginUrl.Query, "appid"), out autoAppId);
autoExit = (getValueFromQueryString(authLoginUrl.Query, "autoexit") == "1"); autoExit = (getValueFromQueryString(authLoginUrl.Query, "autoexit") == "1");
string localPortStr = getValueFromQueryString(authLoginUrl.Query, "localport"); string localPortStr = getValueFromQueryString(authLoginUrl.Query, "localport");
if (localPortStr != null) { autoLocalPort = int.Parse(localPortStr); } if (localPortStr != null) { autoLocalPort = int.Parse(localPortStr); }
} }
catch (Exception) { } catch (Exception) { }
if ((autoRemotePort != 0) && (autoProtocol != 0) && (autoNodeId != null)) { if (((autoRemotePort != 0) && (autoProtocol != 0) && (autoNodeId != null)) || ((autoNodeId != null) && ((autoAppId == 6) || (autoAppId == 7)))) {
Dictionary<string, object> map = new Dictionary<string, object>(); Dictionary<string, object> map = new Dictionary<string, object>();
map.Add("nodeId", autoNodeId); map.Add("nodeId", autoNodeId);
if (autoRemoteIp != null) { map.Add("remoteIP", autoRemoteIp); } if (autoRemoteIp != null) { map.Add("remoteIP", autoRemoteIp); }
@@ -247,7 +247,7 @@ namespace MeshCentralRouter
map.Add("launch", 1); map.Add("launch", 1);
mappingsToSetup = new ArrayList(); mappingsToSetup = new ArrayList();
mappingsToSetup.Add(map); mappingsToSetup.Add(map);
devicesTabControl.SelectedIndex = 1; if ((autoAppId != 6) && (autoAppId != 7)) { devicesTabControl.SelectedIndex = 1; }
} }
} }
@@ -913,15 +913,15 @@ namespace MeshCentralRouter
// Automatic mappings // Automatic mappings
autoNodeId = getValueFromQueryString(authLoginUrl2.Query, "nodeid"); autoNodeId = getValueFromQueryString(authLoginUrl2.Query, "nodeid");
autoRemoteIp = getValueFromQueryString(authLoginUrl2.Query, "remoteip"); autoRemoteIp = getValueFromQueryString(authLoginUrl2.Query, "remoteip");
autoRemotePort = int.Parse(getValueFromQueryString(authLoginUrl2.Query, "remoteport")); int.TryParse(getValueFromQueryString(authLoginUrl2.Query, "remoteport"), out autoRemotePort);
autoProtocol = int.Parse(getValueFromQueryString(authLoginUrl2.Query, "protocol")); int.TryParse(getValueFromQueryString(authLoginUrl2.Query, "protocol"), out autoProtocol);
autoAppId = int.Parse(getValueFromQueryString(authLoginUrl2.Query, "appid")); int.TryParse(getValueFromQueryString(authLoginUrl2.Query, "appid"), out autoAppId);
autoExit = (getValueFromQueryString(authLoginUrl2.Query, "autoexit") == "1"); autoExit = (getValueFromQueryString(authLoginUrl2.Query, "autoexit") == "1");
string localPortStr = getValueFromQueryString(authLoginUrl.Query, "localport"); string localPortStr = getValueFromQueryString(authLoginUrl.Query, "localport");
if (localPortStr != null) { autoLocalPort = int.Parse(localPortStr); } if (localPortStr != null) { autoLocalPort = int.Parse(localPortStr); }
} }
catch (Exception) { } catch (Exception) { }
if ((autoRemotePort != 0) && (autoProtocol != 0) && (autoNodeId != null)) if (((autoRemotePort != 0) && (autoProtocol != 0) && (autoNodeId != null)) || ((autoNodeId != null) && ((autoAppId == 6) || (autoAppId == 7))))
{ {
Dictionary<string, object> map = new Dictionary<string, object>(); Dictionary<string, object> map = new Dictionary<string, object>();
map.Add("nodeId", autoNodeId); map.Add("nodeId", autoNodeId);
@@ -934,7 +934,7 @@ namespace MeshCentralRouter
map.Add("launch", 1); map.Add("launch", 1);
mappingsToSetup = new ArrayList(); mappingsToSetup = new ArrayList();
mappingsToSetup.Add(map); mappingsToSetup.Add(map);
devicesTabControl.SelectedIndex = 1; if ((autoAppId != 6) && (autoAppId != 7)) { devicesTabControl.SelectedIndex = 1; }
setupMappings(); setupMappings();
cancelAutoClose(); cancelAutoClose();
} }
@@ -1568,7 +1568,31 @@ namespace MeshCentralRouter
NodeClass node = null; NodeClass node = null;
try { node = meshcentral.nodes[nodeId]; } catch (Exception) { } try { node = meshcentral.nodes[nodeId]; } catch (Exception) { }
if (node == null) continue; if (node == null) continue;
int appId = (int)x["appId"];
if (appId == 6)
{
// MeshCentral Router Desktop
if ((node.conn & 1) == 0) return; // Agent not connected on this device
startNewDesktopViewer(node, 0);
}
else if (appId == 7)
{
// MeshCentral Router Files
if ((node.conn & 1) == 0) return; // Agent not connected on this device
if (node.fileViewer == null)
{
node.fileViewer = new FileViewer(meshcentral, node);
node.fileViewer.Show();
node.fileViewer.MenuItemConnect_Click(null, null);
}
else
{
node.fileViewer.Focus();
}
}
else
{
// Add a new port map // Add a new port map
MapUserControl map = new MapUserControl(); MapUserControl map = new MapUserControl();
map.xdebug = debug; map.xdebug = debug;
@@ -1591,7 +1615,8 @@ namespace MeshCentralRouter
noMapLabel.Visible = false; noMapLabel.Visible = false;
// Launch any executable // Launch any executable
if (x.ContainsKey("launch")) { if (x.ContainsKey("launch"))
{
if (x["launch"].GetType() == typeof(int)) { map.appButton_Click(this, null); } if (x["launch"].GetType() == typeof(int)) { map.appButton_Click(this, null); }
if (x["launch"].GetType() == typeof(string)) if (x["launch"].GetType() == typeof(string))
{ {
@@ -1605,6 +1630,7 @@ namespace MeshCentralRouter
} }
} }
} }
}
mappingsToSetup = null; mappingsToSetup = null;
} }