New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dispatch-proxy

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dispatch-proxy - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

bin/dispatch.coffee

14

lib/dispatcher/index.js

@@ -1,9 +0,15 @@

var Dispatcher, net, socks,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
var Dispatcher, EventEmitter, net, socks,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
net = require('net');
EventEmitter = require('events').EventEmitter;
socks = require('./socks');
module.exports = Dispatcher = (function() {
module.exports = Dispatcher = (function(_super) {
__extends(Dispatcher, _super);
function Dispatcher(addresses, port, host) {

@@ -58,2 +64,2 @@ this.addresses = addresses;

})();
})(EventEmitter);

@@ -1,2 +0,2 @@

var Dispatcher, SocksDispatcher, clc, net, socks,
var Dispatcher, SocksDispatcher, colog, net, socks,
__hasProp = {}.hasOwnProperty,

@@ -7,3 +7,3 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

clc = require('cli-color');
colog = require('colog');

@@ -34,5 +34,9 @@ socks = require('../socks');

serverConnection.on('error', function(err) {
console.log('\n' + clc.red('serverConnection error: ') + clc.blackBright("" + host + ":" + port + " on " + localAddress.address));
console.log(clc.blackBright(err.stack));
return clientConnection.end();
clientConnection.end();
return _this.emit('error', {
type: 'serverConnection',
host: host,
port: port,
localAddress: localAddress
}, err);
}).on('end', function() {

@@ -45,5 +49,9 @@ _this.connectionsTotal--;

clientConnection.on('error', function(err) {
console.log('\n' + clc.red('clientConnection error: ') + clc.blackBright("" + host + ":" + port + " on " + localAddress.address));
console.log(clc.blackBright(err.stack));
return serverConnection.end();
serverConnection.end();
return this.emit('error', {
type: 'clientConnection',
host: host,
port: port,
localAddress: localAddress
}, err);
});

@@ -54,4 +62,5 @@ clientConnection.pipe(serverConnection);

this.server.on('error', function(err) {
console.log(clc.red('server error'));
return console.log(clc.blackBright(err.stack));
return _this.emit('error', {
type: 'server'
}, err);
});

@@ -58,0 +67,0 @@ this.server.listen(listenPort, listenHost);

@@ -1,2 +0,2 @@

var HttpDispatcher, SocksDispatcher, clc, os, print, program,
var HttpDispatcher, SocksDispatcher, colog, os, print, program,
__slice = [].slice;

@@ -10,3 +10,3 @@

clc = require('cli-color');
colog = require('colog');

@@ -25,6 +25,6 @@ SocksDispatcher = require('./dispatcher/socks');

addrs = interfaces[name];
print(clc.green(name) + '\n');
print((colog.green(name)) + '\n');
for (_i = 0, _len = addrs.length; _i < _len; _i++) {
_ref = addrs[_i], address = _ref.address, family = _ref.family, internal = _ref.internal;
print(' ' + clc.cyan(address));
print(' ' + (colog.cyan(address)));
opts = [];

@@ -38,3 +38,3 @@ if (family) {

if (opts.length > 0) {
print(clc.blackBright(" (" + (opts.join(', ')) + ")"));
print(" (" + (opts.join(', ')) + ")");
}

@@ -49,3 +49,3 @@ print('\n');

program.command('start').usage('[options] [addresses]').description('start a proxy server').option('-H, --host <h>', 'which host to accept connections from (defaults to localhost)', String).option('-p, --port <p>', 'which port to listen to for connections (defaults to 55667)', Number).option('--http', 'start an http proxy server', Boolean).action(function() {
var addr, address, addresses, addrs, arg, args, host, http, https, name, port, priority, type, _arg, _i, _j, _k, _len, _len1, _ref, _ref1;
var addr, address, addresses, addrs, arg, args, dispatcher, host, http, https, name, port, priority, type, _arg, _i, _j, _k, _len, _len1, _ref, _ref1;
args = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), _arg = arguments[_i++];

@@ -83,9 +83,9 @@ port = _arg.port, host = _arg.host, http = _arg.http, https = _arg.https;

type = 'HTTP';
new HttpDispatcher(addresses, port, host);
dispatcher = new HttpDispatcher(addresses, port, host);
} else {
type = 'SOCKS5';
new SocksDispatcher(addresses, port, host);
dispatcher = new SocksDispatcher(addresses, port, host);
}
print(clc.blackBright("" + type + " server started on ") + clc.green("" + host + ":" + port) + '\n');
print(clc.blackBright('Dispatching to addresses '));
print(("" + type + " server started on ") + (colog.green("" + host + ":" + port)) + '\n');
print('Dispatching to addresses ');
print(((function() {

@@ -96,9 +96,18 @@ var _l, _len2, _ref2, _results;

_ref2 = addresses[_l], address = _ref2.address, priority = _ref2.priority;
_results.push(clc.cyan("" + address + "@" + priority));
_results.push(colog.cyan("" + address + "@" + priority));
}
return _results;
})()).join(clc.blackBright(', ')));
return print('\n');
})()).join(', '));
print('\n');
return dispatcher.on('error', function(_arg1, err) {
var host, localAddress , port, type;
type = _arg1.type, host = _arg1.host, port = _arg1.port, localAddress  = _arg1.localAddress ;
if (type === 'server') {
return print(colog.red("" + type + " error"));
} else {
return print((colog.red("" + type + " error: ")) + ("" + host + ":" + port + " on " + localAddress.address));
}
});
});
program.parse(process.argv);

@@ -5,3 +5,3 @@ {

"author": "Alexandre Kirszenberg <a.kirszenberg@gmail.com>",
"version": "0.0.1",
"version": "0.0.2",

@@ -14,3 +14,3 @@ "repository": {

"bin": {
"dispatch": "./bin/dispatch"
"dispatch": "./bin/dispatch.coffee"
},

@@ -23,4 +23,5 @@

"dependencies": {
"coffee-script": "1.6.3",
"commander": "2.0.0",
"cli-color": "0.2.3"
"colog": "1.0.1"
},

@@ -27,0 +28,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