diff --git a/meshuser.js b/meshuser.js index 6a656f19..f13c3445 100644 --- a/meshuser.js +++ b/meshuser.js @@ -461,6 +461,16 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use } serverinfo.https = true; serverinfo.redirport = args.redirport; + + // Build the mobile agent URL, this is used to connect mobile devices + var agentServerName = parent.getWebServerName(domain); + if (typeof parent.args.agentaliasdns == 'string') { agentServerName = parent.args.agentaliasdns; } + var xdomain = (domain.dns == null) ? domain.id : ''; + var agentHttpsPort = ((parent.args.aliasport == null) ? parent.args.port : parent.args.aliasport); // Use HTTPS alias port is specified + if (parent.args.agentport != null) { agentHttpsPort = parent.args.agentport; } // If an agent only port is enabled, use that. + if (parent.args.agentaliasport != null) { agentHttpsPort = parent.args.agentaliasport; } // If an agent alias port is specified, use that. + serverinfo.magenturl = 'mc://' + agentServerName + ((agentHttpsPort != 443)?(':' + agentHttpsPort):'') + ((xdomain != '')?('/' + xdomain):''); + if (domain.guestdevicesharing === false) { serverinfo.guestdevicesharing = false; } if (typeof domain.userconsentflags == 'number') { serverinfo.consent = domain.userconsentflags; } if ((typeof domain.usersessionidletimeout == 'number') && (domain.usersessionidletimeout > 0)) { serverinfo.timeout = (domain.usersessionidletimeout * 60 * 1000); } diff --git a/views/default.handlebars b/views/default.handlebars index af2a1c20..6558acd2 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -4427,11 +4427,7 @@ setDialogMode(2, "Add Mesh Agent", 2, null, x, 'fileDownload'); // Create the QR code - var servername = serverinfo.name; - if ((servername.indexOf('.') == -1) || ((features & 2) != 0)) { servername = window.location.hostname; } // If the server name is not set or it's in LAN-only mode, use the URL hostname as server name. - var domainUrlNoSlash = domainUrl.substring(0, domainUrl.length - 1); - var portStr = (serverinfo.port == 443) ? '' : (':' + serverinfo.port); - new QRCode(Q('agins_qrimage'), { text: 'mc://' + servername + portStr + domainUrlNoSlash + ',' + serverinfo.agentCertHash + ',' + meshid.split('/')[2], width: 180, height: 180, colorDark: '#000000', colorLight: '#EEE', correctLevel: QRCode.CorrectLevel.M }); + new QRCode(Q('agins_qrimage'), { text: serverinfo.magenturl + ',' + serverinfo.agentCertHash + ',' + meshid.split('/')[2], width: 180, height: 180, colorDark: '#000000', colorLight: '#EEE', correctLevel: QRCode.CorrectLevel.M }); if ((features & 0x2000) == 0) {