diff --git a/resources/docs/getting-started.md b/resources/docs/getting-started.md index 9a422489..5ea6f8bc 100644 --- a/resources/docs/getting-started.md +++ b/resources/docs/getting-started.md @@ -32,6 +32,7 @@ Below are the available command-line options. Note that when running without any | |`--disable-vsync` | disable gui's vertical synchronization | | |`--disable-gpu` | disable hardware acceleration | | |`--read-only` | disable session editing and session history changes | +| |`--remote-saving` | disable remote session saving for hosts that don\'t match the regular expresion | | |`--instance-name` | used to differenciate multiple instances in a zeroconf network | | |`--fullscreen` | launch in fullscreen mode (only affects the default gui, F11 to exit) | diff --git a/src/server/callbacks.js b/src/server/callbacks.js index 3e7e974b..ca1e61e7 100644 --- a/src/server/callbacks.js +++ b/src/server/callbacks.js @@ -116,6 +116,10 @@ module.exports = { sessionSetPath: function(data, clientId) { + if (settings.read('remoteSaving') && !RegExp(settings.read('remoteSaving')).test(ipc.clients[clientId].address)) { + return + } + ipc.clients[clientId].sessionPath = '' fs.lstat(data.path, (err, stats)=>{ if (err || !stats.isFile()) return diff --git a/src/server/ipc/client.js b/src/server/ipc/client.js index 84215a1e..c0f06520 100644 --- a/src/server/ipc/client.js +++ b/src/server/ipc/client.js @@ -6,11 +6,14 @@ var hearbeatInterval = 25000, class Socket extends EventEmitter { - constructor(ws, id) { + constructor(ws, id, address) { super() this.id = id + + this.address = address.indexOf('::ffff:') === 0 ? address.replace('::ffff:', '') : address + this.socket = null this.sessionPath = '' diff --git a/src/server/ipc/server.js b/src/server/ipc/server.js index cb2ec945..9e088409 100644 --- a/src/server/ipc/server.js +++ b/src/server/ipc/server.js @@ -21,7 +21,7 @@ class Ipc extends EventEmitter { if (!this.clients[id]) { - var client = new Client(socket, id) + var client = new Client(socket, id, req.connection.remoteAddress) this.clients[id] = client this.emit('connection', client) diff --git a/src/server/settings.js b/src/server/settings.js index f91908f4..0b98b14f 100644 --- a/src/server/settings.js +++ b/src/server/settings.js @@ -79,6 +79,7 @@ var options = { true : 'blank session can\'t be started in read-only mode' } }, + 'remote-saving':{type:'string',describe:'disable remote session saving for hosts that don\'t match the regular expresion'}, 'instance-name':{type:'string',describe:'used to differenciate multiple instances in a zeroconf network'}, 'fullscreen':{type:'boolean', describe:'launch in fullscreen mode (only affects the default gui, F11 to exit)'} } @@ -144,6 +145,7 @@ var makeDefaultConfig = function(argv){ noVsync: argv['disable-vsync'] || false, noGpu: argv['disable-gpu'] || false, readOnly: argv['read-only'] || false, + remoteSaving: argv['remote-saving'] || false, midi: argv['midi'], stateFile: (function(){ if (!argv['state']) return false