-
Notifications
You must be signed in to change notification settings - Fork 25
/
direct.js
31 lines (27 loc) · 826 Bytes
/
direct.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
var debug = require('debug')('PROTO:DIRECT')
, http = require('http')
, net = require('net');
// Socket
function createConnection(){ // port,host,options
var options = {};
if (typeof arguments[0] === 'object') {
options = arguments[0];
} else if (typeof arguments[1] === 'object') {
options = arguments[1];
options.port = arguments[0];
} else if (typeof arguments[2] === 'object') {
options = arguments[2];
options.port = arguments[0];
options.host = arguments[1];
} else {
if (typeof arguments[0] === 'number') {
options.port = arguments[0];
}
if (typeof arguments[1] === 'string') {
options.host = arguments[1];
}
}
var socks = new net.Socket();
return socks.connect(options.port, options.host);
};
exports.createConnection = createConnection;