Added SSH file operation log.
This commit is contained in:
parent
5757811b9c
commit
f3c180a2c2
32
apprelays.js
32
apprelays.js
|
@ -165,7 +165,6 @@ module.exports.CreateMstscRelay = function (parent, db, ws, req, args, domain) {
|
||||||
|
|
||||||
// Construct a SSH Relay object, called upon connection
|
// Construct a SSH Relay object, called upon connection
|
||||||
module.exports.CreateSshRelay = function (parent, db, ws, req, args, domain) {
|
module.exports.CreateSshRelay = function (parent, db, ws, req, args, domain) {
|
||||||
console.log('CreateSshRelay');
|
|
||||||
const Net = require('net');
|
const Net = require('net');
|
||||||
const WebSocket = require('ws');
|
const WebSocket = require('ws');
|
||||||
|
|
||||||
|
@ -795,7 +794,12 @@ module.exports.CreateSshFilesRelay = function (parent, db, ws, req, domain, user
|
||||||
if (obj.sftp == null) return;
|
if (obj.sftp == null) return;
|
||||||
var requestedPath = msg.path;
|
var requestedPath = msg.path;
|
||||||
if (requestedPath.startsWith('/') == false) { requestedPath = '/' + requestedPath; }
|
if (requestedPath.startsWith('/') == false) { requestedPath = '/' + requestedPath; }
|
||||||
obj.sftp.mkdir(requestedPath, function (err) { console.log(err); });
|
obj.sftp.mkdir(requestedPath, function (err) { });
|
||||||
|
|
||||||
|
// Event the file delete
|
||||||
|
var targets = ['*', 'server-users'];
|
||||||
|
if (user.groups) { for (var i in user.groups) { targets.push('server-users:' + i); } }
|
||||||
|
parent.parent.DispatchEvent(targets, obj, { etype: 'node', action: 'agentlog', nodeid: obj.nodeid, userid: user._id, username: user.name, msgid: 44, msgArgs: [requestedPath], msg: 'Create folder: \"' + requestedPath + '\"', domain: domain.id });
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'rm': {
|
case 'rm': {
|
||||||
|
@ -806,7 +810,13 @@ module.exports.CreateSshFilesRelay = function (parent, db, ws, req, domain, user
|
||||||
const ul = obj.path.join(requestedPath, msg.delfiles[i]).split('\\').join('/');
|
const ul = obj.path.join(requestedPath, msg.delfiles[i]).split('\\').join('/');
|
||||||
obj.sftp.unlink(ul, function (err) { });
|
obj.sftp.unlink(ul, function (err) { });
|
||||||
if (msg.rec === true) { obj.sftp.rmdir(ul + '/', function (err) { }); }
|
if (msg.rec === true) { obj.sftp.rmdir(ul + '/', function (err) { }); }
|
||||||
|
|
||||||
|
// Event the file delete
|
||||||
|
var targets = ['*', 'server-users'];
|
||||||
|
if (user.groups) { for (var i in user.groups) { targets.push('server-users:' + i); } }
|
||||||
|
parent.parent.DispatchEvent(targets, obj, { etype: 'node', action: 'agentlog', nodeid: obj.nodeid, userid: user._id, username: user.name, msgid: 45, msgArgs: [ul], msg: 'Delete: \"' + ul + '\"', domain: domain.id });
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'rename': {
|
case 'rename': {
|
||||||
|
@ -816,6 +826,11 @@ module.exports.CreateSshFilesRelay = function (parent, db, ws, req, domain, user
|
||||||
const oldpath = obj.path.join(requestedPath, msg.oldname).split('\\').join('/');
|
const oldpath = obj.path.join(requestedPath, msg.oldname).split('\\').join('/');
|
||||||
const newpath = obj.path.join(requestedPath, msg.newname).split('\\').join('/');
|
const newpath = obj.path.join(requestedPath, msg.newname).split('\\').join('/');
|
||||||
obj.sftp.rename(oldpath, newpath, function (err) { });
|
obj.sftp.rename(oldpath, newpath, function (err) { });
|
||||||
|
|
||||||
|
// Event the file rename
|
||||||
|
var targets = ['*', 'server-users'];
|
||||||
|
if (user.groups) { for (var i in user.groups) { targets.push('server-users:' + i); } }
|
||||||
|
parent.parent.DispatchEvent(targets, obj, { etype: 'node', action: 'agentlog', nodeid: obj.nodeid, userid: user._id, username: user.name, msgid: 48, msgArgs: [oldpath, msg.newname], msg: 'Rename: \"' + oldpath + '\" to \"' + msg.newname + '\"', domain: domain.id });
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'upload': {
|
case 'upload': {
|
||||||
|
@ -832,6 +847,11 @@ module.exports.CreateSshFilesRelay = function (parent, db, ws, req, domain, user
|
||||||
} else {
|
} else {
|
||||||
obj.uploadHandle = handle;
|
obj.uploadHandle = handle;
|
||||||
try { obj.ws.send(Buffer.from(JSON.stringify({ action: 'uploadstart', reqid: obj.uploadReqid }))) } catch (ex) { }
|
try { obj.ws.send(Buffer.from(JSON.stringify({ action: 'uploadstart', reqid: obj.uploadReqid }))) } catch (ex) { }
|
||||||
|
|
||||||
|
// Event the file upload
|
||||||
|
var targets = ['*', 'server-users'];
|
||||||
|
if (user.groups) { for (var i in user.groups) { targets.push('server-users:' + i); } }
|
||||||
|
parent.parent.DispatchEvent(targets, obj, { etype: 'node', action: 'agentlog', nodeid: obj.nodeid, userid: user._id, username: user.name, msgid: 105, msgArgs: [obj.uploadFullpath, obj.uploadSize], msg: 'Upload: ' + obj.uploadFullpath + ', Size: ' + obj.uploadSize, domain: domain.id });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
@ -878,8 +898,12 @@ module.exports.CreateSshFilesRelay = function (parent, db, ws, req, domain, user
|
||||||
try { obj.ws.send(Buffer.from(JSON.stringify({ action: 'download', sub: 'cancel', id: obj.downloadId }))) } catch (ex) { }
|
try { obj.ws.send(Buffer.from(JSON.stringify({ action: 'download', sub: 'cancel', id: obj.downloadId }))) } catch (ex) { }
|
||||||
} else {
|
} else {
|
||||||
obj.downloadHandle = handle;
|
obj.downloadHandle = handle;
|
||||||
// MeshServerLogEx((cmd.ask == 'coredump') ? 104 : 49, [cmd.path], 'Download: \"' + cmd.path + '\"', this.httprequest);
|
|
||||||
try { obj.ws.send(JSON.stringify({ action: 'download', sub: 'start', id: obj.downloadId })) } catch (ex) { }
|
try { obj.ws.send(JSON.stringify({ action: 'download', sub: 'start', id: obj.downloadId })) } catch (ex) { }
|
||||||
|
|
||||||
|
// Event the file download
|
||||||
|
var targets = ['*', 'server-users'];
|
||||||
|
if (user.groups) { for (var i in user.groups) { targets.push('server-users:' + i); } }
|
||||||
|
parent.parent.DispatchEvent(targets, obj, { etype: 'node', action: 'agentlog', nodeid: obj.nodeid, userid: user._id, username: user.name, msgid: 49, msgArgs: [obj.downloadFullpath], msg: 'Download: ' + obj.downloadFullpath, domain: domain.id });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
@ -927,7 +951,7 @@ module.exports.CreateSshFilesRelay = function (parent, db, ws, req, domain, user
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (ex) { console.log(ex); obj.close(); }
|
} catch (ex) { obj.close(); }
|
||||||
});
|
});
|
||||||
|
|
||||||
function uploadNextBlock() {
|
function uploadNextBlock() {
|
||||||
|
|
Loading…
Reference in New Issue