1.0.0 • Published 9 years ago

node-socks-client v1.0.0

Weekly downloads
2
License
ISC
Repository
-
Last release
9 years ago

#node-socks-client

Yet another SOCKS5 client for Node.js

Works as a either a socket proxy or as a HTTP agent.

Usage

Create a client

  var client = new SocksClient({
    socksHost: 'localhost',
    socksPort: '1080',
    username: null,
    password: null,
    destAddr: '192.168.1.1',
    destPort: 80
  });

Connect

Initiate a connection to the socks server and returns a usable socket

  client.on('connected', function(socket){
    socket.write('Hazaa!', "UTF8");
  });
  client.connect();

Disconnect

Disconnect from the socks server

  client.on('connected', function(socket){
    socket.write('Hazaa!', "UTF8");
  });
  client.connect();

Agent

Returns an HTTP agent

  var options = {
    host: "173.194.33.161",
    method: "GET"
  };
  options.agent = SocksClient.agent(creds);
  http.get(options, function(res){
    console.log('STATUS: ' + res.statusCode);
    console.log('HEADERS: ' + JSON.stringify(res.headers));
    res.setEncoding('utf8');
    res.on('data', function (chunk) {
      console.log('BODY: ' + chunk);
    });
    res.on('end', function(){
      done();
    });
  });
});

Events

These are pretty self explanatory

  • Connecting
  • Authenticating
  • Authenticated
  • Connected
  • Disconnected

Notes

  • Authentication supports "No Authentication" and "Username/Password"
  • Does not support Bind or UDP Associate commands

TODOs

  • DNS lookup
  • HTTPS support
1.0.0

9 years ago