Fixed meshcore.js on Linux with no X, translation fixes.

This commit is contained in:
Ylian Saint-Hilaire 2020-01-18 12:48:25 -08:00
parent a89b7401cf
commit f5444863aa
6 changed files with 1027 additions and 902 deletions

View File

@ -1191,14 +1191,14 @@ function createMeshCore(agent) {
var bash = fs.existsSync('/bin/bash') ? '/bin/bash' : false; var bash = fs.existsSync('/bin/bash') ? '/bin/bash' : false;
var sh = fs.existsSync('/bin/sh') ? '/bin/sh' : false; var sh = fs.existsSync('/bin/sh') ? '/bin/sh' : false;
var script = false; var script = false;
if (require('linux-gnome-helpers').scriptVersion) try {
{ if (require('linux-gnome-helpers').scriptVersion) {
if (require('linux-gnome-helpers').scriptVersion.major > 2 || if (require('linux-gnome-helpers').scriptVersion.major > 2 ||
(require('linux-gnome-helpers').scriptVersion.major == 2 && require('linux-gnome-helpers').scriptVersion.minor >= 25)) (require('linux-gnome-helpers').scriptVersion.major == 2 && require('linux-gnome-helpers').scriptVersion.minor >= 25)) {
{ script = '/usr/bin/script';
script = '/usr/bin/script'; }
} }
} } catch (ex) { }
var python = fs.existsSync('/usr/bin/python') ? '/usr/bin/python' : false; var python = fs.existsSync('/usr/bin/python') ? '/usr/bin/python' : false;
var shell = bash || sh; var shell = bash || sh;

View File

@ -1,6 +1,6 @@
{ {
"name": "meshcentral", "name": "meshcentral",
"version": "0.4.7-j", "version": "0.4.7-k",
"keywords": [ "keywords": [
"Remote Management", "Remote Management",
"Intel AMT", "Intel AMT",

View File

@ -220,11 +220,71 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort, au
return obj.m.ProcessData(data); return obj.m.ProcessData(data);
} }
// TODO: Optimize this
function toUTF8Array(str) {
var utf8 = [];
for (var i = 0; i < str.length; i++) {
var charcode = str.charCodeAt(i);
if (charcode < 0x80) utf8.push(charcode);
else if (charcode < 0x800) {
utf8.push(0xc0 | (charcode >> 6),
0x80 | (charcode & 0x3f));
}
else if (charcode < 0xd800 || charcode >= 0xe000) {
utf8.push(0xe0 | (charcode >> 12),
0x80 | ((charcode >> 6) & 0x3f),
0x80 | (charcode & 0x3f));
}
// surrogate pair
else {
i++;
charcode = ((charcode & 0x3ff) << 10) | (str.charCodeAt(i) & 0x3ff)
utf8.push(0xf0 | (charcode >> 18),
0x80 | ((charcode >> 12) & 0x3f),
0x80 | ((charcode >> 6) & 0x3f),
0x80 | (charcode & 0x3f));
}
}
var ret = new Uint8Array(utf8.length);
for (i = 0; i < utf8.length; ++i) {
ret[i] = utf8[i];
}
return ret;
}
obj.sendText = function (x) { obj.sendText = function (x) {
if (typeof x != 'string') { x = JSON.stringify(x); } // Turn into a string if needed if (typeof x != 'string') { x = JSON.stringify(x); } // Turn into a string if needed
obj.send(encode_utf8(x)); // Encode UTF8 correctly obj.send(encode_utf8(x)); // Encode UTF8 correctly
} }
// TODO: Optimize this
obj.send = function (x) {
//obj.debug('Agent Redir Send(' + obj.webRtcActive + ', ' + x.length + '): ' + rstr2hex(x));
//console.log('Agent Redir Send(' + obj.webRtcActive + ', ' + x.length + '): ' + ((typeof x == 'string')?x:rstr2hex(x)));
if ((typeof args != 'undefined') && args.redirtrace) { console.log('RedirSend', typeof x, x.length, (x[0] == '{') ? x : rstr2hex(x).substring(0, 64)); }
try {
if (obj.socket != null && obj.socket.readyState == WebSocket.OPEN) {
if (typeof x == 'string') {
if (obj.debugmode == 1) {
var b = new Uint8Array(x.length), c = [];
for (var i = 0; i < x.length; ++i) { b[i] = x.charCodeAt(i); c.push(x.charCodeAt(i)); }
if (obj.webRtcActive == true) { obj.webchannel.send(b.buffer); } else { obj.socket.send(toUTF8Array(x));/*obj.socket.send(b.buffer);*/ }
//console.log('Send', c);
} else {
var b = new Uint8Array(x.length);
for (var i = 0; i < x.length; ++i) { b[i] = x.charCodeAt(i); }
if (obj.webRtcActive == true) { obj.webchannel.send(b.buffer); } else { obj.socket.send(toUTF8Array(x)); /*obj.socket.send(b.buffer); */ }
}
} else {
//if (obj.debugmode == 1) { console.log('Send', x); }
if (obj.webRtcActive == true) { obj.webchannel.send(x); } else { obj.socket.send(toUTF8Array(x)); /*obj.socket.send(x);*/ }
}
}
} catch (ex) { }
}
/*
obj.send = function (x) { obj.send = function (x) {
//obj.debug('Agent Redir Send(' + obj.webRtcActive + ', ' + x.length + '): ' + rstr2hex(x)); //obj.debug('Agent Redir Send(' + obj.webRtcActive + ', ' + x.length + '): ' + rstr2hex(x));
//console.log('Agent Redir Send(' + obj.webRtcActive + ', ' + x.length + '): ' + ((typeof x == 'string')?x:rstr2hex(x))); //console.log('Agent Redir Send(' + obj.webRtcActive + ', ' + x.length + '): ' + ((typeof x == 'string')?x:rstr2hex(x)));
@ -249,6 +309,7 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort, au
} }
} catch (ex) { } } catch (ex) { }
} }
*/
obj.xxOnSocketClosed = function () { obj.xxOnSocketClosed = function () {
//obj.debug('Agent Redir Socket Closed'); //obj.debug('Agent Redir Socket Closed');

File diff suppressed because it is too large Load Diff

View File

@ -258,8 +258,8 @@
if (serverHttps == 1) { if (serverHttps == 1) {
var portStr = (serverPort == 443) ? '' : (":" + serverPort); var portStr = (serverPort == 443) ? '' : (":" + serverPort);
if (serverNoProxy == 0) { if (serverNoProxy == 0) {
linuxInstall = '(wget https://' + servername + portStr + domainUrl + 'meshagents?script=1 --no-check-certificate -O ./meshinstall.sh || wget https://" + servername + portStr + domainUrl + "meshagents?script=1 --no-proxy --no-check-certificate -O ./meshinstall.sh) && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh https://' + servername + portStr + domainUrlNoSlash + ' \'' + meshid + '\'\r\n'; linuxInstall = '(wget https://' + servername + portStr + domainUrl + 'meshagents?script=1 --no-check-certificate -O ./meshinstall.sh || wget https://' + servername + portStr + domainUrl + 'meshagents?script=1 --no-proxy --no-check-certificate -O ./meshinstall.sh) && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh https://' + servername + portStr + domainUrlNoSlash + ' \'' + meshid + '\'\r\n';
linuxUnInstall = '(wget https://' + servername + portStr + domainUrl + 'meshagents?script=1 --no-check-certificate -O ./meshinstall.sh || wget https://" + servername + portStr + domainUrl + "meshagents?script=1 --no-proxy --no-check-certificate -O ./meshinstall.sh) && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh uninstall\r\n'; linuxUnInstall = '(wget https://' + servername + portStr + domainUrl + 'meshagents?script=1 --no-check-certificate -O ./meshinstall.sh || wget https://' + servername + portStr + domainUrl + 'meshagents?script=1 --no-proxy --no-check-certificate -O ./meshinstall.sh) && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh uninstall\r\n';
} else { } else {
// Server asked that agent be installed to preferably not use a HTTP proxy. // Server asked that agent be installed to preferably not use a HTTP proxy.
linuxInstall = 'wget https://' + servername + portStr + domainUrl + 'meshagents?script=1 --no-proxy --no-check-certificate -O ./meshinstall.sh && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh https://' + servername + portStr + domainUrlNoSlash + ' \'' + meshid + '\'\r\n'; linuxInstall = 'wget https://' + servername + portStr + domainUrl + 'meshagents?script=1 --no-proxy --no-check-certificate -O ./meshinstall.sh && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh https://' + servername + portStr + domainUrlNoSlash + ' \'' + meshid + '\'\r\n';
@ -268,8 +268,8 @@
} else { } else {
var portStr = (serverPort == 80) ? '' : (':' + serverPort); var portStr = (serverPort == 80) ? '' : (':' + serverPort);
if (serverNoProxy == 0) { if (serverNoProxy == 0) {
linuxInstall = '(wget http://' + servername + portStr + domainUrl + 'meshagents?script=1 -O ./meshinstall.sh || wget http://" + servername + portStr + domainUrl + "meshagents?script=1 --no-proxy -O ./meshinstall.sh) && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh http://' + servername + portStr + domainUrlNoSlash + ' \'' + meshid + '\'\r\n'; linuxInstall = '(wget http://' + servername + portStr + domainUrl + 'meshagents?script=1 -O ./meshinstall.sh || wget http://' + servername + portStr + domainUrl + 'meshagents?script=1 --no-proxy -O ./meshinstall.sh) && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh http://' + servername + portStr + domainUrlNoSlash + ' \'' + meshid + '\'\r\n';
linuxUnInstall = '(wget http://' + servername + portStr + domainUrl + 'meshagents?script=1 -O ./meshinstall.sh || wget http://" + servername + portStr + domainUrl + "meshagents?script=1 --no-proxy -O ./meshinstall.sh) && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh uninstall\r\n'; linuxUnInstall = '(wget http://' + servername + portStr + domainUrl + 'meshagents?script=1 -O ./meshinstall.sh || wget http://' + servername + portStr + domainUrl + 'meshagents?script=1 --no-proxy -O ./meshinstall.sh) && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh uninstall\r\n';
} else { } else {
// Server asked that agent be installed to preferably not use a HTTP proxy. // Server asked that agent be installed to preferably not use a HTTP proxy.
linuxInstall = 'wget http://' + servername + portStr + domainUrl + 'meshagents?script=1 --no-proxy -O ./meshinstall.sh && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh http://' + servername + portStr + domainUrlNoSlash + ' \'' + meshid + '\'\r\n'; linuxInstall = 'wget http://' + servername + portStr + domainUrl + 'meshagents?script=1 --no-proxy -O ./meshinstall.sh && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh http://' + servername + portStr + domainUrlNoSlash + ' \'' + meshid + '\'\r\n';

View File

@ -5273,12 +5273,12 @@
y += '</select>'; y += '</select>';
var x = ''; var x = '';
if (mode == 0) { x += '<div>MeshCmd is a command line tool that performs lots of different operations. The action file can optionally be downloaded and edited to provide server information and credentials.<br /><br />'; } if (mode == 0) { x += '<div>' + "MeshCmd is a command line tool that performs lots of different operations. The action file can optionally be downloaded and edited to provide server information and credentials." + '<br /><br />'; }
if (mode == 1) { x += '<div>Download "meshcmd" with an action file to route traffic thru this server to this device. Make sure to edit meshaction.txt and add your account password or make any changes needed.<br /><br />'; } if (mode == 1) { x += '<div>' + "Download \"meshcmd\" with an action file to route traffic thru this server to this device. Make sure to edit meshaction.txt and add your account password or make any changes needed." + '<br /><br />'; }
x += addHtmlValue('Operating System', y); x += addHtmlValue("Operating System", y);
x += addHtmlValue('MeshCmd', '<a id=meshcmddownloadid href="meshagents?meshcmd=3" download></a>'); x += addHtmlValue("MeshCmd", '<a id=meshcmddownloadid href="meshagents?meshcmd=3" download></a>');
if (mode == 0) { x += addHtmlValue('Action File', '<a href="meshagents?meshaction=generic" download>MeshAction (.txt)</a>'); } if (mode == 0) { x += addHtmlValue("Action File", '<a href="meshagents?meshaction=generic" download>' + "MeshAction (.txt)" + '</a>'); }
if (mode == 1) { x += addHtmlValue('Action File', '<a href="meshagents?meshaction=route&nodeid=' + nodeid + '" download>MeshAction (.txt)</a>'); } if (mode == 1) { x += addHtmlValue("Action File", '<a href="meshagents?meshaction=route&nodeid=' + nodeid + '" download>' + "MeshAction (.txt)" + '</a>'); }
x += '</div>'; x += '</div>';
setDialogMode(2, [ "Download MeshCmd", "Network Router" ][mode], 9, null, x, 'fileDownload'); setDialogMode(2, [ "Download MeshCmd", "Network Router" ][mode], 9, null, x, 'fileDownload');
meshCmdOsClick(); meshCmdOsClick();
@ -5287,12 +5287,12 @@
function meshCmdOsClick() { function meshCmdOsClick() {
var os = Q('aginsSelect').value, osn = '', osurl = ''; var os = Q('aginsSelect').value, osn = '', osurl = '';
//Q('meshcmddownloadid').href = 'meshagents?meshcmd=' + os; //Q('meshcmddownloadid').href = 'meshagents?meshcmd=' + os;
if (os == 3) { osn = 'MeshCmd (Win32 executable)'; } if (os == 3) { osn = "MeshCmd (Win32 executable)"; }
if (os == 4) { osn = 'MeshCmd (Win64 executable)'; } if (os == 4) { osn = "MeshCmd (Win64 executable)"; }
if (os == 5) { osn = 'MeshCmd (Linux x86, 32bit)'; } if (os == 5) { osn = "MeshCmd (Linux x86, 32bit)"; }
if (os == 6) { osn = 'MeshCmd (Linux x86, 64bit)'; } if (os == 6) { osn = "MeshCmd (Linux x86, 64bit)"; }
if (os == 16) { osn = 'MeshCmd (MacOS, 64bit)'; } if (os == 16) { osn = "MeshCmd (MacOS, 64bit)"; }
if (os == 25) { osn = 'MeshCmd (Linux ARM, 32bit)'; } if (os == 25) { osn = "MeshCmd (Linux ARM, 32bit)"; }
QH('meshcmddownloadid', osn); QH('meshcmddownloadid', osn);
Q('meshcmddownloadid').setAttribute('href', 'meshagents?meshcmd=' + os); Q('meshcmddownloadid').setAttribute('href', 'meshagents?meshcmd=' + os);
} }