Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ssh-pool

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ssh-pool - npm Package Compare versions

Comparing version 1.4.0 to 1.4.1

2

examples/hostname.js
var sshPool = require('../');
var pool = new sshPool.ConnectionPool(['neoziro@localhost', 'neoziro@localhost'], 'neoziro@proxyhost');
var pool = new sshPool.ConnectionPool(['neoziro@localhost', 'neoziro@localhost']);

@@ -5,0 +5,0 @@ pool.run('hostname')

@@ -15,7 +15,7 @@ var _ = require('lodash');

function ConnectionPool(connections, proxy, options) {
function ConnectionPool(connections, options) {
// Create connection if necessary.
this.connections = connections.map(function (connection) {
if (connection instanceof Connection) return connection;
return new Connection(_.extend({remote: connection, proxy: proxy}, options));
return new Connection(_.extend({remote: connection}, options));
});

@@ -22,0 +22,0 @@ }

@@ -30,10 +30,5 @@ var _ = require('lodash');

this.options.remote;
this.proxy = _.isString(this.options.proxy) ?
remote.parse(this.options.proxy) :
null;
this.sshArgs = buildSSHArgs({
key: this.options.key,
port: _.isString(this.options.proxy) ?
this.proxy.port :
this.remote.port,
port: this.remote.port,
strict: this.options.strict

@@ -62,11 +57,4 @@ });

// In sudo mode, we use a TTY channel.
var args = /^sudo/.exec(command) ? ['ssh -tt'] : ['ssh'];
var args = /^sudo/.exec(command) ? ['-tt'] : [];
args.push.apply(args, connection.sshArgs);
// Add proxy to the chain
if (this.proxy) {
args.push(remote.format(connection.proxy));
args.push(/^sudo/.exec(command) ? ['ssh -tt'] : ['ssh']);
}
args.push(remote.format(connection.remote));

@@ -78,3 +66,3 @@

// Complete arguments.
args = args.concat(['"' + command + '"']);
args = ['ssh'].concat(args).concat(['"' + command + '"']);

@@ -81,0 +69,0 @@ return args.join(' ');

{
"name": "ssh-pool",
"version": "1.4.0",
"version": "1.4.1",
"description": "Run remote commands over a pool of server using SSH.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -37,3 +37,2 @@ # ssh-pool

@param {string|object} options.remote Remote
@param {string|object} options.proxy Proxy
@param {Stream} [options.stdout] Stdout stream

@@ -57,5 +56,2 @@ @param {Stream} [options.stderr] Stderr stream

// Connecting to remote host via proxy.
new Connection({remote: 'user@remotehost', proxy: 'user@proxyhost'});
// Object syntax.

@@ -62,0 +58,0 @@ new Connection({remote: {user: 'user', host: 'localhost', port: 22}});

@@ -122,13 +122,2 @@ var rewire = require('rewire');

it('should connect via proxy if present', function () {
connection = new Connection({
remote: 'user@host',
proxy: 'user@proxy'
});
connection.run('my-command -x', function () {});
expect(childProcess.exec).to.be.calledWith(
'ssh user@proxy ssh user@host "my-command -x"'
);
});
it('should use StrictHostKeyChecking if present', function () {

@@ -156,14 +145,2 @@ connection = new Connection({

it('should connect via proxy and use port and key if both are present', function () {
connection = new Connection({
remote: 'user@host',
proxy: 'user@proxy:12345',
key: '/path/to/key'
});
connection.run('my-command -x', function () {});
expect(childProcess.exec).to.be.calledWith(
'ssh -p 12345 -i /path/to/key user@proxy ssh user@host "my-command -x"'
);
});
it('should log output', function (done) {

@@ -179,4 +156,4 @@ connection = new Connection({

connection.run('my-command -x', function (err, res) {
// res.child.stdout.push('first line\n');
// res.child.stdout.push(null);
res.child.stdout.push('first line\n');
res.child.stdout.push(null);

@@ -189,3 +166,4 @@ res.child.stderr.push('an error\n');

expect(output.stdout[0]).to.equal('Running "my-command -x" on host "host".\n');
// expect(output.stdout[1].toString()).to.equal('@host first line\n');
expect(output.stdout[1].toString()).to.equal('@host first line\n');
expect(output.stderr[0].toString()).to.equal('@host-err an error\n');

@@ -192,0 +170,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc