mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-09-11 08:55:32 +03:00
Added option to allow framing.
This commit is contained in:
parent
1aa0e80f53
commit
400f853732
Binary file not shown.
Binary file not shown.
@ -64,16 +64,16 @@ function createMeshCore(agent) {
|
||||
// If we are running in Duktape, agent will be null
|
||||
if (agent == null) {
|
||||
// Running in native agent, Import libraries
|
||||
var db = require('SimpleDataStore').Shared();
|
||||
var sha = require('SHA256Stream');
|
||||
var mesh = require('MeshAgent');
|
||||
var processManager = require('ILibProcessPipe');
|
||||
db = require('SimpleDataStore').Shared();
|
||||
sha = require('SHA256Stream');
|
||||
mesh = require('MeshAgent');
|
||||
processManager = require('ILibProcessPipe');
|
||||
if (mesh.hasKVM == 1) { obj.meshCoreCapabilities |= 1; }
|
||||
} else {
|
||||
// Running in nodejs
|
||||
obj.meshCoreInfo += '-NodeJS';
|
||||
obj.meshCoreCapabilities = 8;
|
||||
var mesh = agent.getMeshApi();
|
||||
mesh = agent.getMeshApi();
|
||||
}
|
||||
|
||||
// Get our location (lat/long) using our public IP address
|
||||
@ -464,7 +464,9 @@ function createMeshCore(agent) {
|
||||
}
|
||||
function onTunnelSendOk() { sendConsoleText("Tunnel #" + this.index + " SendOK.", this.sessionid); }
|
||||
function onTunnelData(data) {
|
||||
console.log("OnTunnelData");
|
||||
//console.log("OnTunnelData");
|
||||
//sendConsoleText('OnTunnelData, ' + data.length + ', ' + typeof data + ', ' + data);
|
||||
|
||||
// If this is upload data, save it to file
|
||||
if (this.httprequest.uploadFile) {
|
||||
try { fs.writeSync(this.httprequest.uploadFile, data); } catch (e) { this.write(JSON.stringify({ action: 'uploaderror' })); return; } // Write to the file, if there is a problem, error out.
|
||||
@ -530,8 +532,8 @@ function createMeshCore(agent) {
|
||||
}
|
||||
this.httprequest.process.tunnel = this;
|
||||
this.httprequest.process.error.data = function (chunk) { this.parent.tunnel.write(chunk); }
|
||||
this.httprequest.process.pipe(this);
|
||||
this.pipe(this.httprequest.process);
|
||||
this.httprequest.process.pipe(this, { dataTypeSkip: 1 }); // 0 = Binary, 1 = Text.
|
||||
this.pipe(this.httprequest.process, { dataTypeSkip: 1 }); // 0 = Binary, 1 = Text.
|
||||
}
|
||||
}
|
||||
if (this.httprequest.protocol == 2) {
|
||||
@ -555,8 +557,11 @@ function createMeshCore(agent) {
|
||||
if (this.desktop.kvm.connectionCount == 0) { this.httprequest.desktop.kvm.end(); }
|
||||
};
|
||||
if (this.httprequest.desktop.kvm.hasOwnProperty("connectionCount")) { this.httprequest.desktop.kvm.connectionCount++; } else { this.httprequest.desktop.kvm.connectionCount = 1; }
|
||||
this.pipe(this.httprequest.desktop.kvm);
|
||||
this.httprequest.desktop.kvm.pipe(this);
|
||||
//this.write('Hello!');
|
||||
//sendConsoleText('KVM WriteHello');
|
||||
this.pipe(this.httprequest.desktop.kvm, { dataTypeSkip: 1 }); // 0 = Binary, 1 = Text.
|
||||
this.httprequest.desktop.kvm.pipe(this, { dataTypeSkip: 1 }); // 0 = Binary, 1 = Text.
|
||||
//this.on('data', function (data) { sendConsoleText('KVM: ' + data); });
|
||||
}
|
||||
}
|
||||
else if (this.httprequest.protocol == 5) {
|
||||
@ -704,6 +709,7 @@ function createMeshCore(agent) {
|
||||
response += '\r\nModules: ' + JSON.stringify(addedModules) + '';
|
||||
var oldNodeId = db.Get('OldNodeId');
|
||||
if (oldNodeId != null) { response += '\r\nOldNodeID: ' + oldNodeId + '.'; }
|
||||
response += '\r\ServerState: ' + meshServerConnectionState + '.';
|
||||
break;
|
||||
}
|
||||
case 'selfinfo': { // Return self information block
|
||||
@ -1002,7 +1008,7 @@ function createMeshCore(agent) {
|
||||
|
||||
// Called periodically to check if we need to send updates to the server
|
||||
function sendPeriodicServerUpdate(force) {
|
||||
if (amtMeiConnected != 1) { // If we are pending MEI connection, hold off on updating the server on self-info
|
||||
if ((amtMeiConnected != 1) || (force == true)) { // If we are pending MEI connection, hold off on updating the server on self-info
|
||||
// Update the self information data
|
||||
var selfInfo = buildSelfInfo(), selfInfoStr = JSON.stringify(selfInfo);
|
||||
if ((force == true) || (selfInfoStr != lastSelfInfo)) { mesh.SendCommand(selfInfo); lastSelfInfo = selfInfoStr; }
|
||||
@ -1071,7 +1077,7 @@ function createMeshCore(agent) {
|
||||
mesh.AddCommandHandler(handleServerCommand);
|
||||
mesh.AddConnectHandler(handleServerConnection);
|
||||
//mesh.lmsNotification = handleAmtNotification; // TODO
|
||||
sendPeriodicServerUpdate(); // TODO: Check if connected before sending
|
||||
sendPeriodicServerUpdate(true); // TODO: Check if connected before sending
|
||||
|
||||
// Parse input arguments
|
||||
//var args = parseArgs(process.argv);
|
||||
|
@ -180,7 +180,7 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain) {
|
||||
|
||||
// When data is received from the mesh relay web socket
|
||||
ws.on('message', function (data) {
|
||||
//console.log(typeof data);
|
||||
//console.log(typeof data, data.length);
|
||||
//if (typeof data == 'string') console.log(data);
|
||||
if (this.peer != null) { try { this.pause(); this.peer.send(data, ws.flushSink); } catch (e) { } }
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "meshcentral",
|
||||
"version": "0.1.1-f",
|
||||
"version": "0.1.1-h",
|
||||
"keywords": [
|
||||
"Remote Management",
|
||||
"Intel AMT",
|
||||
|
@ -47,6 +47,8 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort) {
|
||||
|
||||
// Called to pass websocket control messages
|
||||
obj.xxOnControlCommand = function (msg) {
|
||||
//console.log(msg);
|
||||
//obj.socket.send('hellobob');
|
||||
var controlMsg = JSON.parse(msg);
|
||||
if ((controlMsg.type == 'answer') && (obj.webrtc != null)) {
|
||||
console.log('gotAnswer', JSON.stringify(controlMsg));
|
||||
@ -106,8 +108,7 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort) {
|
||||
if (typeof e.data == 'string') {
|
||||
// Control messages, most likely WebRTC setup
|
||||
obj.xxOnControlCommand(e.data);
|
||||
}
|
||||
if (typeof e.data == 'object') {
|
||||
} else if (typeof e.data == 'object') {
|
||||
var f = new FileReader();
|
||||
if (f.readAsBinaryString) {
|
||||
// Chrome & Firefox (Draft)
|
||||
|
@ -636,10 +636,12 @@
|
||||
var clickOnce = detectClickOnce();
|
||||
|
||||
function startup() {
|
||||
// Guard against other site's top frames (web bugs).
|
||||
var loc = null;
|
||||
try { loc = top.location.toString().toLowerCase(); } catch (e) { }
|
||||
if (top != self && (loc == null || top.active == false)) { top.location = self.location; return; }
|
||||
if ((features & 32) == 0) {
|
||||
// Guard against other site's top frames (web bugs).
|
||||
var loc = null;
|
||||
try { loc = top.location.toString().toLowerCase(); } catch (e) { }
|
||||
if (top != self && (loc == null || top.active == false)) { top.location = self.location; return; }
|
||||
}
|
||||
|
||||
// Check if we are in debug mode
|
||||
args = parseUriArgs();
|
||||
@ -754,7 +756,7 @@
|
||||
hideContextMenu(); // Hide the context menu if present
|
||||
QV('verifyEmailId2', false);
|
||||
QV('logoutControl', false);
|
||||
serverPoll();
|
||||
setTimeout(serverPoll, 5000);
|
||||
} else if (state == 2) {
|
||||
// Fetch list of meshes, nodes, files
|
||||
meshserver.Send({ action: 'meshes' });
|
||||
|
@ -169,8 +169,16 @@
|
||||
var passhint = "{{{passhint}}}";
|
||||
var newAccountPass = {{{newAccountPass}}};
|
||||
var emailCheck = {{{emailcheck}}};
|
||||
var features = {{{features}}};
|
||||
|
||||
function startup() {
|
||||
if ((features & 32) == 0) {
|
||||
// Guard against other site's top frames (web bugs).
|
||||
var loc = null;
|
||||
try { loc = top.location.toString().toLowerCase(); } catch (e) { }
|
||||
if (top != self && (loc == null || top.active == false)) { top.location = self.location; return; }
|
||||
}
|
||||
|
||||
window.onresize = center;
|
||||
center();
|
||||
validateLogin();
|
||||
|
@ -613,13 +613,16 @@ module.exports.CreateWebServer = function (parent, db, args, secret, certificate
|
||||
if (obj.args.nousers == true) { features += 4; } // Single user mode
|
||||
if (domain.userQuota == -1) { features += 8; } // No server files mode
|
||||
if (obj.args.tlsoffload == true) { features += 16; } // No mutual-auth CIRA
|
||||
if (parent.config.settings.allowFraming == true) { features += 32; } // Allow site within iframe
|
||||
if ((!obj.args.user) && (obj.args.nousers != true)) { logoutcontrol += ' <a href=' + domain.url + 'logout?' + Math.random() + ' style=color:white>Logout</a>'; } // If a default user is in use or no user mode, don't display the logout button
|
||||
res.render(obj.path.join(__dirname, 'views/default'), { viewmode: viewmode, currentNode: currentNode, logoutControl: logoutcontrol, title: domain.title, title2: domain.title2, domainurl: domain.url, domain: domain.id, debuglevel: parent.debugLevel, serverDnsName: obj.certificates.CommonName, serverRedirPort: args.redirport, serverPublicPort: args.port, noServerBackup: (args.noserverbackup == 1 ? 1 : 0), features: features, mpspass: args.mpspass, webcerthash: obj.webCertificateHashBase64 });
|
||||
} else {
|
||||
// Send back the login application
|
||||
var loginmode = req.session.loginmode;
|
||||
delete req.session.loginmode; // Clear this state, if the user hits refresh, we want to go back to the login page.
|
||||
res.render(obj.path.join(__dirname, 'views/login'), { loginmode: loginmode, rootCertLink: getRootCertLink(), title: domain.title, title2: domain.title2, newAccount: domain.newaccounts, newAccountPass: (((domain.newaccountspass == null) || (domain.newaccountspass == '')) ? 0 : 1), serverDnsName: obj.certificates.CommonName, serverPublicPort: obj.args.port, emailcheck: obj.parent.mailserver != null });
|
||||
var features = 0;
|
||||
if (parent.config.settings.allowFraming == true) { features += 32; } // Allow site within iframe
|
||||
res.render(obj.path.join(__dirname, 'views/login'), { loginmode: loginmode, rootCertLink: getRootCertLink(), title: domain.title, title2: domain.title2, newAccount: domain.newaccounts, newAccountPass: (((domain.newaccountspass == null) || (domain.newaccountspass == '')) ? 0 : 1), serverDnsName: obj.certificates.CommonName, serverPublicPort: obj.args.port, emailcheck: obj.parent.mailserver != null, features: features });
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user