Socket
Book a DemoInstallSign in
Socket

abstractsocket

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abstractsocket

Abstract unix sockets support by spawning socat process

latest
npmnpm
Version
0.0.3
Version published
Maintainers
1
Created
Source

abstractsocket

abstract unix sockets support for net.createConnection

var net = require('net');
require('abstractsocket')(net);
var connection = net.createConnection('\u0000/tmp/dbus-OeixI07RHo');
connection.pipe(process.stdout);
connection.write(Buffer('\0AUTH EXTERNAL 31303030\r\n'));

you can map net.createConnection to any command:

var net = require('net');
var url = require('url');
require('abstractsocket')(net, {
    getSpawnArguments: function(path) {
        if (path.match(/^ssh\+exec:\/\//)) {
           var params = url.parse(path, true);
           var args = [];
           if (params.port)
           {
               args.push('-p');
               args.push(params.port.toString());
           }
           var user = params.auth.split(':')[0];
           args.push(user + '@' + params.hostname);
           args.push(params.query.command);
           console.log(args);
           return ['ssh', args];
        }
        // if not matched, createConnection is called 
    }
});

// list files on remote machine
var lsStream = net.createConnection('ssh+exec://user@domain.com:2222/?command=ls%20-l');
lsStream.pipe(process.stdout);

Keywords

child

FAQs

Package last updated on 27 Sep 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts