mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-26 23:25:53 -05:00
Fixed MeshMessenger connection issue.
This commit is contained in:
parent
a087c5d2fc
commit
bd8cc18225
@ -149,7 +149,11 @@ function createMeshCore(agent) {
|
||||
};
|
||||
this._daipc = c;
|
||||
c.parent = this;
|
||||
c.on('end', function () { this.end(); this.parent._daipc = null; }); // TODO: Must call end() on self to close the named pipe correctly.
|
||||
c.on('end', function () {
|
||||
this.end(); // TODO: Must call end() on self to close the named pipe correctly.
|
||||
this.parent._daipc = null;
|
||||
if (this._registered != null) { try { mesh.SendCommand({ action: 'sessions', type: 'app', value: {} }); } catch (e) { } }
|
||||
});
|
||||
c.on('data', function (chunk) {
|
||||
if (chunk.length < 4) { this.unshift(chunk); return; }
|
||||
var len = chunk.readUInt32LE(0);
|
||||
@ -162,6 +166,15 @@ function createMeshCore(agent) {
|
||||
|
||||
try {
|
||||
switch (data.cmd) {
|
||||
case 'register':
|
||||
if (typeof data.value == 'string') {
|
||||
this._registered = data.value;
|
||||
var apps = {};
|
||||
apps[data.value] = 1;
|
||||
try { mesh.SendCommand({ action: 'sessions', type: 'app', value: apps }); } catch (e) { }
|
||||
this._send({ cmd: 'serverstate', value: meshServerConnectionState, url: require('MeshAgent').ConnectedServer });
|
||||
}
|
||||
break;
|
||||
case 'query':
|
||||
switch (data.value) {
|
||||
case 'connection':
|
||||
@ -3572,6 +3585,16 @@ function createMeshCore(agent) {
|
||||
try { mesh.SendCommand({ action: 'sessions', type: 'msg', value: tunnelUserCount.msg }); } catch (e) { }
|
||||
}
|
||||
}
|
||||
|
||||
// Send update to the registered application
|
||||
if ((obj.DAIPC._daipc != null) && (obj.DAIPC._daipc._registered != null)) {
|
||||
if (state == 1) {
|
||||
var apps = {};
|
||||
apps[obj.DAIPC._daipc._registered] = 1;
|
||||
try { mesh.SendCommand({ action: 'sessions', type: 'app', value: apps }); } catch (e) { }
|
||||
}
|
||||
obj.DAIPC._daipc._send({ cmd: 'serverstate', value: meshServerConnectionState, url: require('MeshAgent').ConnectedServer });
|
||||
}
|
||||
}
|
||||
|
||||
// Update the server with the latest network interface information
|
||||
|
15
meshagent.js
15
meshagent.js
@ -1378,12 +1378,15 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
||||
case 'sessions': {
|
||||
// This is a list of sessions provided by the agent
|
||||
if (obj.sessions == null) { obj.sessions = {}; }
|
||||
if (command.type == 'kvm') { obj.sessions.kvm = command.value; }
|
||||
else if (command.type == 'terminal') { obj.sessions.terminal = command.value; }
|
||||
else if (command.type == 'files') { obj.sessions.files = command.value; }
|
||||
else if (command.type == 'tcp') { obj.sessions.tcp = command.value; }
|
||||
else if (command.type == 'udp') { obj.sessions.udp = command.value; }
|
||||
else if (command.type == 'msg') { obj.sessions.msg = command.value; }
|
||||
if (typeof command.value != null) {
|
||||
if (command.type == 'kvm') { obj.sessions.kvm = command.value; }
|
||||
else if (command.type == 'terminal') { obj.sessions.terminal = command.value; }
|
||||
else if (command.type == 'files') { obj.sessions.files = command.value; }
|
||||
else if (command.type == 'tcp') { obj.sessions.tcp = command.value; }
|
||||
else if (command.type == 'udp') { obj.sessions.udp = command.value; }
|
||||
else if (command.type == 'msg') { obj.sessions.msg = command.value; }
|
||||
else if (command.type == 'app') { obj.sessions.app = command.value; }
|
||||
}
|
||||
obj.updateSessions();
|
||||
break;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@
|
||||
var userInputFocus = 0;
|
||||
var socket = null; // Websocket object
|
||||
var state = 0; // Connection state. 0 = Disconnected, 1 = Connecting, 2 = Connected.
|
||||
var args = parseUriArgs();
|
||||
var args = XparseUriArgs();
|
||||
if (args.key && (isAlphaNumeric(args.key) == false)) { delete args.key; }
|
||||
if (args.locale && (isAlphaNumeric(args.locale) == false)) { delete args.locale; }
|
||||
|
||||
@ -656,6 +656,23 @@
|
||||
if (socket != null) { try { socket.close(); } catch (e) { } socket = null; }
|
||||
}
|
||||
|
||||
function isSafeString3(str) { return ((typeof str == 'string') && (str.indexOf('<') == -1) && (str.indexOf('>') == -1) && (str.indexOf('&') == -1) && (str.indexOf('"') == -1) && (str.indexOf('\'') == -1) && (str.indexOf('+') == -1) && (str.indexOf('(') == -1) && (str.indexOf(')') == -1) && (str.indexOf('#') == -1) && (str.indexOf(':') == -1)) };
|
||||
|
||||
// Parse URL arguments, only keep safe values
|
||||
function XparseUriArgs() {
|
||||
var href = window.document.location.href;
|
||||
if (href.endsWith('#')) { href = href.substring(0, href.length - 1); }
|
||||
var name, r = {}, parsedUri = href.split(/[\?&|]/);
|
||||
parsedUri.splice(0, 1);
|
||||
for (var j in parsedUri) {
|
||||
var arg = parsedUri[j], i = arg.indexOf('=');
|
||||
name = arg.substring(0, i);
|
||||
r[name] = arg.substring(i + 1);
|
||||
if (!isSafeString3(r[name])) { delete r[name]; } else { var x = parseInt(r[name]); if (x == r[name]) { r[name] = x; } }
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user