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

Merge pull request #55 from jbfuzier/wol

Wol
This commit is contained in:
Ylian Saint-Hilaire
2023-10-07 12:16:40 -07:00
committed by GitHub
5 changed files with 94 additions and 38 deletions

View File

@@ -108,6 +108,7 @@
this.rdpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.sshToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.scpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.wolToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.devicesImageList = new System.Windows.Forms.ImageList(this.components);
this.noSearchResultsLabel = new System.Windows.Forms.Label();
this.noDevicesLabel = new System.Windows.Forms.Label();
@@ -677,7 +678,9 @@
this.httpsToolStripMenuItem,
this.rdpToolStripMenuItem,
this.sshToolStripMenuItem,
this.scpToolStripMenuItem});
this.scpToolStripMenuItem,
this.wolToolStripMenuItem,
});
this.devicesContextMenuStrip.Name = "devicesContextMenuStrip";
resources.ApplyResources(this.devicesContextMenuStrip, "devicesContextMenuStrip");
this.devicesContextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(this.devicesContextMenuStrip_Opening);
@@ -763,6 +766,12 @@
resources.ApplyResources(this.scpToolStripMenuItem, "scpToolStripMenuItem");
this.scpToolStripMenuItem.Click += new System.EventHandler(this.scpToolStripMenuItem_Click);
//
// wolToolStripMenuItem
//
this.wolToolStripMenuItem.Name = "wolToolStripMenuItem";
resources.ApplyResources(this.wolToolStripMenuItem, "wolToolStripMenuItem");
this.wolToolStripMenuItem.Click += new System.EventHandler(this.wolToolStripMenuItem_Click);
//
// devicesImageList
//
this.devicesImageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("devicesImageList.ImageStream")));
@@ -1137,6 +1146,7 @@
private System.Windows.Forms.ToolStripMenuItem rdpToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem sshToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem scpToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem wolToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem addMapToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem addRelayMapToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem3;

View File

@@ -2063,24 +2063,43 @@ 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) && (node.mtype != 3)) { e.Cancel = true; return; } // Agent not connected on this device
if (node.agentid < 6)
{
// Windows OS
wolToolStripMenuItem.Visible = false;
if (((node.conn & 1) == 0) && (node.mtype != 3))
{ // Agent not connected on this device and not local device
addMapToolStripMenuItem.Visible = false;
addRelayMapToolStripMenuItem.Visible = false;
remoteDesktopToolStripMenuItem.Visible = false;
remoteFilesToolStripMenuItem.Visible = false;
httpToolStripMenuItem.Visible = false;
httpsToolStripMenuItem.Visible = false;
rdpToolStripMenuItem.Visible = false;
sshToolStripMenuItem.Visible = false;
scpToolStripMenuItem.Visible = false;
rdpToolStripMenuItem.Visible = true;
wolToolStripMenuItem.Visible = true; // Wol not allowed for local devices
}
else
{
// Other OS
sshToolStripMenuItem.Visible = true;
scpToolStripMenuItem.Visible = true;
rdpToolStripMenuItem.Visible = false;
else{ // Agent connected or local device
if (node.agentid < 6)
{
// Windows OS
sshToolStripMenuItem.Visible = false;
scpToolStripMenuItem.Visible = false;
rdpToolStripMenuItem.Visible = true;
}
else
{
// Other OS
sshToolStripMenuItem.Visible = true;
scpToolStripMenuItem.Visible = true;
rdpToolStripMenuItem.Visible = false;
}
addMapToolStripMenuItem.Visible = true;
httpToolStripMenuItem.Visible = true;
httpsToolStripMenuItem.Visible = true;
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)
}
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)
@@ -2130,6 +2149,18 @@ namespace MeshCentralRouter
QuickMap(1, 22, 5, node); // WinSCP
}
private void wolToolStripMenuItem_Click(object sender, EventArgs e)
{
if (devicesListView.SelectedItems.Count != 1) { return; }
ListViewItem selecteditem = devicesListView.SelectedItems[0];
NodeClass node = (NodeClass)selecteditem.Tag;
if (((node.conn & 1) != 0) || (node.mtype == 3)) { return; } // Agent connected on this device or local device
// List of actions : https://github.com/Ylianst/MeshCentral/blob/f5db131693386147731f2ec93b9378bf035b5861/agents/meshcore.js#L1110
// https://github.com/Ylianst/MeshCentral/blob/f5db131693386147731f2ec93b9378bf035b5861/amtmanager.js#L347
// https://github.com/Ylianst/MeshCentral/blob/f5db131693386147731f2ec93b9378bf035b5861/meshuser.js#L5285
meshcentral.sendCommand("{ \"action\": \"wakedevices\", \"nodeids\": [\"" + node.nodeid + "\"]}");
}
private void addMapToolStripMenuItem_Click(object sender, EventArgs e)
{
if (devicesListView.SelectedItems.Count != 1) { return; }

View File

@@ -1695,6 +1695,12 @@
<data name="remoteFilesToolStripMenuItem.Text" xml:space="preserve">
<value>Remote Files...</value>
</data>
<data name="wolToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>198, 24</value>
</data>
<data name="wolToolStripMenuItem.Text" xml:space="preserve">
<value>Wake Up...</value>
</data>
<data name="httpToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>198, 24</value>
</data>
@@ -6243,6 +6249,12 @@ Click "Add" to get started.</value>
<data name="&gt;&gt;remoteFilesToolStripMenuItem.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;wolToolStripMenuItem.Name" xml:space="preserve">
<value>wolToolStripMenuItem</value>
</data>
<data name="&gt;&gt;wolToolStripMenuItem.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;httpToolStripMenuItem.Name" xml:space="preserve">
<value>httpToolStripMenuItem</value>
</data>

View File

@@ -4086,6 +4086,29 @@ namespace MeshCentralRouter
{"ru","Спросите согласия"}
}
},
{
"Wake Up...",
new Dictionary<string, string>() {
{"de","Wach auf..."},
{"hi","जगाना..."},
{"fr","Reveiller..."},
{"zh-chs","醒来..."},
{"fi","herätä..."},
{"tr","uyanmak..."},
{"cs","vzbudit..."},
{"ja","起きろ..."},
{"es","despertar..."},
{"pl","budzić się..."},
{"pt","acordar..."},
{"nl","word wakker..."},
{"pt-br","acordar..."},
{"sv","vakna..."},
{"da","Vågn op..."},
{"ko","깨우다..."},
{"it","svegliati..."},
{"ru","просыпайся..."}
}
},
{
"Remote Desktop...",
new Dictionary<string, string>() {

View File

@@ -209,30 +209,9 @@ namespace MeshCentralRouter
else
{
// Use C# coded websockets
Uri proxyUri = null;
Uri proxyUri = Win32Api.GetProxy(url);
Log("Websocket Start, URL=" + ((url == null) ? "(NULL)" : url.ToString()));
// Check if we need to use a HTTP proxy (Auto-proxy way)
try
{
RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true);
Object x = registryKey.GetValue("AutoConfigURL", null);
if ((x != null) && (x.GetType() == typeof(string)))
{
string proxyStr = GetProxyForUrlUsingPac("http" + ((url.Port == 80) ? "" : "s") + "://" + url.Host + ":" + url.Port, x.ToString());
if (proxyStr != null) { proxyUri = new Uri("http://" + proxyStr); }
}
}
catch (Exception) { proxyUri = null; }
// Check if we need to use a HTTP proxy (Normal way)
if (proxyUri == null)
{
var proxy = System.Net.HttpWebRequest.GetSystemWebProxy();
proxyUri = proxy.GetProxy(url);
if ((url.Host.ToLower() == proxyUri.Host.ToLower()) && (url.Port == proxyUri.Port)) { proxyUri = null; }
}
if (proxyUri != null)
{
// Proxy in use
@@ -288,7 +267,8 @@ namespace MeshCentralRouter
{
// Send proxy connection request
wsrawstream = wsclient.GetStream();
Uri proxyUri = Win32Api.GetProxy(url);
string userCreds = proxyUri.UserInfo;
string basicAuth = "";
if (proxyUri?.UserInfo != null)
{