forked from brozeph/simple-socks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateServer.js
38 lines (31 loc) · 1.02 KB
/
createServer.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
32
33
34
35
36
37
38
const
socks5 = require('../dist/socks5'),
server = socks5.createServer();
// start listening!
server.listen(1080);
server.on('handshake', function (socket) {
console.log();
console.log('------------------------------------------------------------');
console.log('new socks5 client from %s:%d', socket.remoteAddress, socket.remotePort);
});
// When a reqest arrives for a remote destination
server.on('proxyConnect', function (info, destination) {
console.log('connected to remote server at %s:%d', info.address, info.port);
destination.on('data', function (data) {
console.log(data.length);
});
});
server.on('proxyData', function (data) {
console.log(data.length);
});
// When an error occurs connecting to remote destination
server.on('proxyError', function (err) {
console.error('unable to connect to remote server');
console.error(err);
});
// When a proxy connection ends
server.on('proxyEnd', function (response, args) {
console.log('socket closed with code %d', response);
console.log(args);
console.log();
});