Fixed mobile QR code when using non-standard port.

This commit is contained in:
Ylian Saint-Hilaire 2021-01-29 02:23:46 -08:00
parent b6ebca0bd4
commit 516a763c1b
2 changed files with 11 additions and 5 deletions

View File

@ -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); }

View File

@ -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)
{