diff --git a/demo.js b/demo.js index dd6b0ed..2108172 100644 --- a/demo.js +++ b/demo.js @@ -2,11 +2,11 @@ const autossh = require('./index.js'); // open 5 ssh tunnels -for (let i = 0; i < 5; i++) { +// for (let i = 0; i < 5; i++) { // set up config autossh({ - host: 'xyz.xy.xyz.yz', // enter host address + host: '192.241.216.152', // enter host address username: 'same', // enter username localPort: 'auto', // 'auto' or port number remotePort: 5432 @@ -23,7 +23,7 @@ for (let i = 0; i < 5; i++) { console.log(`tunnel established from localhost:${connection.localPort} to ${connection.host}:${connection.remotePort} as ${connection.username}`); }); -} +// } /* Possible output example (localPort results are be random) diff --git a/index.js b/index.js index eabf9d1..e96d684 100644 --- a/index.js +++ b/index.js @@ -50,7 +50,7 @@ var AutoSSH = function (_EventEmitter) { }); var port = _this.localPort === 'auto' ? _this.generateRandomPort() : _this.localPort; - console.log('checkpoint 1'); + _portfinder2.default.getPort({ port: port }, function (err, freePort) { if (err) return _this.emit('error', 'Port error: ' + err); if (_this.localPort !== 'auto' && _this.localPort !== freePort) return _this.emit('error', 'Port ' + _this.localPort + ' is not available'); diff --git a/src/index.js b/src/index.js index 9b884b5..bab259a 100644 --- a/src/index.js +++ b/src/index.js @@ -24,7 +24,7 @@ class AutoSSH extends EventEmitter { return confErrors.forEach(err => this.emit('error', err)); const port = this.localPort === 'auto' ? this.generateRandomPort() : this.localPort; - console.log('checkpoint 1'); + portfinder.getPort({ port }, (err, freePort) => { if (err) return this.emit('error', 'Port error: ' + err);