mirror of
https://github.com/Ylianst/MeshCentralRouter
synced 2025-12-06 00:13:33 +00:00
Fixed auth cookie freshness issue.
This commit is contained in:
12
MainForm.cs
12
MainForm.cs
@@ -940,7 +940,7 @@ namespace MeshCentralRouter
|
||||
map.appId = 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.authCookie = meshcentral.authCookie;
|
||||
map.certhash = meshcentral.wshash;
|
||||
map.parent = this;
|
||||
map.Dock = DockStyle.Top;
|
||||
@@ -1002,7 +1002,7 @@ namespace MeshCentralRouter
|
||||
map.appId = 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.authCookie = meshcentral.authCookie;
|
||||
map.certhash = meshcentral.wshash;
|
||||
map.parent = this;
|
||||
map.Dock = DockStyle.Top;
|
||||
@@ -1043,7 +1043,7 @@ namespace MeshCentralRouter
|
||||
map.appId = form.getAppId();
|
||||
map.node = form.getNode();
|
||||
if (authLoginUrl != null) { map.host = authLoginUrl.Host + ":" + ((authLoginUrl.Port > 0) ? authLoginUrl.Port : 443); } else { map.host = serverNameComboBox.Text; }
|
||||
map.authCookie = meshcentral.authCookie;
|
||||
//map.authCookie = meshcentral.authCookie;
|
||||
map.certhash = meshcentral.wshash;
|
||||
map.parent = this;
|
||||
map.Dock = DockStyle.Top;
|
||||
@@ -1202,7 +1202,7 @@ namespace MeshCentralRouter
|
||||
map.appId = form.getAppId();
|
||||
map.node = form.getNode();
|
||||
if (authLoginUrl != null) { map.host = authLoginUrl.Host + ":" + ((authLoginUrl.Port > 0) ? authLoginUrl.Port : 443); } else { map.host = serverNameComboBox.Text; }
|
||||
map.authCookie = meshcentral.authCookie;
|
||||
//map.authCookie = meshcentral.authCookie;
|
||||
map.certhash = meshcentral.wshash;
|
||||
map.parent = this;
|
||||
map.Dock = DockStyle.Top;
|
||||
@@ -1357,7 +1357,7 @@ namespace MeshCentralRouter
|
||||
map.appId = appId; // 0 = Custom, 1 = HTTP, 2 = HTTPS, 3 = RDP, 4 = PuTTY, 5 = WinSCP
|
||||
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.authCookie = meshcentral.authCookie;
|
||||
map.certhash = meshcentral.wshash;
|
||||
map.parent = this;
|
||||
map.Dock = DockStyle.Top;
|
||||
@@ -1511,7 +1511,7 @@ namespace MeshCentralRouter
|
||||
if (x.ContainsKey("autoExit")) { map.autoexit = (bool)x["autoExit"]; }
|
||||
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.authCookie = meshcentral.authCookie;
|
||||
map.certhash = meshcentral.wshash;
|
||||
map.parent = this;
|
||||
map.Dock = DockStyle.Top;
|
||||
|
||||
1696
MainForm.resx
1696
MainForm.resx
File diff suppressed because it is too large
Load Diff
@@ -24,7 +24,7 @@ namespace MeshCentralRouter
|
||||
public MainForm parent;
|
||||
public MeshMapper mapper;
|
||||
public string host;
|
||||
public string authCookie;
|
||||
//public string authCookie;
|
||||
public string certhash;
|
||||
public bool xdebug = false;
|
||||
public bool inaddrany = false;
|
||||
@@ -67,7 +67,7 @@ namespace MeshCentralRouter
|
||||
mapper.inaddrany = inaddrany;
|
||||
mapper.certhash = certhash;
|
||||
mapper.onStateMsgChanged += Mapper_onStateMsgChanged;
|
||||
string serverurl = "wss://" + host + "/meshrelay.ashx?auth=" + Uri.EscapeDataString(authCookie) + "&nodeid=" + node.nodeid;
|
||||
string serverurl = "wss://" + host + "/meshrelay.ashx?nodeid=" + node.nodeid;
|
||||
if (protocol == 1) {
|
||||
serverurl += ("&tcpport=" + remotePort);
|
||||
if (remoteIP != null) { serverurl += "&tcpaddr=" + remoteIP; }
|
||||
@@ -75,7 +75,7 @@ namespace MeshCentralRouter
|
||||
serverurl += ("&udpport=" + remotePort);
|
||||
if (remoteIP != null) { serverurl += "&udpaddr=" + remoteIP; }
|
||||
}
|
||||
mapper.start(protocol, localPort, serverurl, remotePort, remoteIP);
|
||||
mapper.start(parent.meshcentral, protocol, localPort, serverurl, remotePort, remoteIP);
|
||||
UpdateInfo();
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,9 @@ namespace MeshCentralRouter
|
||||
{
|
||||
public class MeshMapper
|
||||
{
|
||||
public MeshCentralServer parent = null;
|
||||
public int state = 0;
|
||||
Uri wsurl = null;
|
||||
public string url = null;
|
||||
public int protocol = 1; // 1 = TCP, 2 = UDP
|
||||
public int localport = 0;
|
||||
public int remoteport = 0;
|
||||
@@ -67,12 +68,13 @@ namespace MeshCentralRouter
|
||||
}
|
||||
|
||||
// Starts the routing server, called when the start button is pressed
|
||||
public void start(int protocol, int localPort, string url, int remotePort, string remoteIP)
|
||||
public void start(MeshCentralServer parent, int protocol, int localPort, string url, int remotePort, string remoteIP)
|
||||
{
|
||||
this.parent = parent;
|
||||
this.protocol = protocol;
|
||||
this.remoteport = remotePort;
|
||||
this.remoteip = remoteIP;
|
||||
wsurl = new Uri(url);
|
||||
this.url = url;
|
||||
//wshash = serverHashTextBox.Text;
|
||||
|
||||
Debug(string.Format("MeshMapper-Start: Protcol={0}, LocalPort={1}, Url={2}, RemotePort={3}, RemoteIP={4}", protocol, localPort, url, remotePort, remoteIP));
|
||||
@@ -202,6 +204,7 @@ namespace MeshCentralRouter
|
||||
private void ConnectWS(TcpClient client, int counter)
|
||||
{
|
||||
webSocketClient wc = new webSocketClient();
|
||||
Uri wsurl = new Uri(url + "&auth=" + Uri.EscapeDataString(parent.authCookie));
|
||||
Debug("#" + counter + ": Connecting web socket to: " + wsurl.ToString());
|
||||
wc.xdebug = xdebug;
|
||||
wc.Start(wsurl, certhash);
|
||||
@@ -215,6 +218,7 @@ namespace MeshCentralRouter
|
||||
private void ConnectWS(UdpClient client, int counter)
|
||||
{
|
||||
webSocketClient wc = new webSocketClient();
|
||||
Uri wsurl = new Uri(url + "&auth=" + Uri.EscapeDataString(parent.authCookie));
|
||||
Debug("#" + counter + ": Connecting web socket to: " + wsurl.ToString());
|
||||
wc.xdebug = xdebug;
|
||||
wc.Start(wsurl, certhash);
|
||||
|
||||
Reference in New Issue
Block a user