Added AgentAliasDNS settings option
Ylian Saint-Hilaire committed
May 10, 2020 at 13:45 UTC
a28f717fd59b13a48228f6596a7a34a0f0198bc8
2 files changed
+16
-3
sample-config.json
+1
@@ -26,6 +26,7 @@
26
"_RedirAliasPort": 80,
27
"_AgentPort": 1234,
28
"_AgentAliasPort": 1234,
29
+ "_AgentAliasDNS": "agents.myserver.mydomain.com",
30
"_ExactPorts": true,
31
"_AllowLoginToken": true,
32
"_AllowFraming": true,
webserver.js
+15
-3
@@ -3454,11 +3454,15 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
3454
meshfilename = meshfilename.split('\\').join('').split('/').join('').split(':').join('').split('*').join('').split('?').join('').split('"').join('').split('<').join('').split('>').join('').split('|').join('').split(' ').join('').split('\'').join('');
3455
if (argentInfo.rname.endsWith('.exe')) { meshfilename = argentInfo.rname.substring(0, argentInfo.rname.length - 4) + '-' + meshfilename + '.exe'; } else { meshfilename = argentInfo.rname + '-' + meshfilename; }
3456
3457
+ // Get the agent connection server name
3458
+ var serverName = obj.getWebServerName(domain);
3459
+ if (typeof obj.args.agentaliasdns == 'string') { serverName = obj.args.agentaliasdns; }
3460
+
3461
// Build the agent connection URL. If we are using a sub-domain or one with a DNS, we need to craft the URL correctly.
3462
var xdomain = (domain.dns == null) ? domain.id : '';
3463
if (xdomain != '') xdomain += '/';
3464
var meshsettings = 'MeshName=' + mesh.name + '\r\nMeshType=' + mesh.mtype + '\r\nMeshID=0x' + meshidhex + '\r\nServerID=' + serveridhex + '\r\n';
3461
- if (obj.args.lanonly != true) { meshsettings += 'MeshServer=ws' + (obj.args.notls ? '' : 's') + '://' + obj.getWebServerName(domain) + ':' + httpsPort + '/' + xdomain + 'agent.ashx\r\n'; } else { meshsettings += 'MeshServer=local\r\n'; }
3465
+ if (obj.args.lanonly != true) { meshsettings += 'MeshServer=ws' + (obj.args.notls ? '' : 's') + '://' + serverName + ':' + httpsPort + '/' + xdomain + 'agent.ashx\r\n'; } else { meshsettings += 'MeshServer=local\r\n'; }
3466
if (req.query.tag != null) { meshsettings += 'Tag=' + req.query.tag + '\r\n'; }
3467
if ((req.query.installflags != null) && (req.query.installflags != 0)) { meshsettings += 'InstallFlags=' + req.query.installflags + '\r\n'; }
3468
if ((domain.agentnoproxy === true) || (obj.args.lanonly == true)) { meshsettings += 'ignoreProxyFile=1\r\n'; }
@@ -3624,13 +3628,17 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
3628
var meshidhex = Buffer.from(req.query.meshid.replace(/\@/g, '+').replace(/\$/g, '/'), 'base64').toString('hex').toUpperCase();
3629
var serveridhex = Buffer.from(obj.agentCertificateHashBase64.replace(/\@/g, '+').replace(/\$/g, '/'), 'base64').toString('hex').toUpperCase();
3630
3631
+ // Get the agent connection server name
3632
+ var serverName = obj.getWebServerName(domain);
3633
+ if (typeof obj.args.agentaliasdns == 'string') { serverName = obj.args.agentaliasdns; }
3634
+
3635
// Build the agent connection URL. If we are using a sub-domain or one with a DNS, we need to craft the URL correctly.
3636
var xdomain = (domain.dns == null) ? domain.id : '';
3637
if (xdomain != '') xdomain += '/';
3638
var meshsettings = 'MeshName=' + mesh.name + '\r\nMeshType=' + mesh.mtype + '\r\nMeshID=0x' + meshidhex + '\r\nServerID=' + serveridhex + '\r\n';
3639
var httpsPort = ((obj.args.aliasport == null) ? obj.args.port : obj.args.aliasport); // Use HTTPS alias port is specified
3640
if (obj.args.agentaliasport != null) { httpsPort = obj.args.agentaliasport; } // If an agent alias port is specified, use that.
3633
- if (obj.args.lanonly != true) { meshsettings += 'MeshServer=ws' + (obj.args.notls ? '' : 's') + '://' + obj.getWebServerName(domain) + ':' + httpsPort + '/' + xdomain + 'agent.ashx\r\n'; } else { meshsettings += 'MeshServer=local\r\n'; }
3641
+ if (obj.args.lanonly != true) { meshsettings += 'MeshServer=ws' + (obj.args.notls ? '' : 's') + '://' + serverName + ':' + httpsPort + '/' + xdomain + 'agent.ashx\r\n'; } else { meshsettings += 'MeshServer=local\r\n'; }
3642
if (req.query.tag != null) { meshsettings += 'Tag=' + req.query.tag + '\r\n'; }
3643
if ((req.query.installflags != null) && (req.query.installflags != 0)) { meshsettings += 'InstallFlags=' + req.query.installflags + '\r\n'; }
3644
if ((domain.agentnoproxy === true) || (obj.args.lanonly == true)) { meshsettings += 'ignoreProxyFile=1\r\n'; }
@@ -3712,13 +3720,17 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
3720
var meshidhex = Buffer.from(req.query.id.replace(/\@/g, '+').replace(/\$/g, '/'), 'base64').toString('hex').toUpperCase();
3721
var serveridhex = Buffer.from(obj.agentCertificateHashBase64.replace(/\@/g, '+').replace(/\$/g, '/'), 'base64').toString('hex').toUpperCase();
3722
3723
+ // Get the agent connection server name
3724
+ var serverName = obj.getWebServerName(domain);
3725
+ if (typeof obj.args.agentaliasdns == 'string') { serverName = obj.args.agentaliasdns; }
3726
+
3727
// Build the agent connection URL. If we are using a sub-domain or one with a DNS, we need to craft the URL correctly.
3728
var xdomain = (domain.dns == null) ? domain.id : '';
3729
if (xdomain != '') xdomain += '/';
3730
var meshsettings = 'MeshName=' + mesh.name + '\r\nMeshType=' + mesh.mtype + '\r\nMeshID=0x' + meshidhex + '\r\nServerID=' + serveridhex + '\r\n';
3731
var httpsPort = ((obj.args.aliasport == null) ? obj.args.port : obj.args.aliasport); // Use HTTPS alias port is specified
3732
if (obj.args.agentaliasport != null) { httpsPort = obj.args.agentaliasport; } // If an agent alias port is specified, use that.
3721
- if (obj.args.lanonly != true) { meshsettings += 'MeshServer=ws' + (obj.args.notls ? '' : 's') + '://' + obj.getWebServerName(domain) + ':' + httpsPort + '/' + xdomain + 'agent.ashx\r\n'; } else { meshsettings += 'MeshServer=local\r\n'; }
3733
+ if (obj.args.lanonly != true) { meshsettings += 'MeshServer=ws' + (obj.args.notls ? '' : 's') + '://' + serverName + ':' + httpsPort + '/' + xdomain + 'agent.ashx\r\n'; } else { meshsettings += 'MeshServer=local\r\n'; }
3734
if (req.query.tag != null) { meshsettings += 'Tag=' + req.query.tag + '\r\n'; }
3735
if ((req.query.installflags != null) && (req.query.installflags != 0)) { meshsettings += 'InstallFlags=' + req.query.installflags + '\r\n'; }
3736
if ((domain.agentnoproxy === true) || (obj.args.lanonly == true)) { meshsettings += 'ignoreProxyFile=1\r\n'; }