-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtunnel.js
More file actions
32 lines (26 loc) · 803 Bytes
/
tunnel.js
File metadata and controls
32 lines (26 loc) · 803 Bytes
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
var http = require('http');
var port = process.env.PORT||5000,proxySocket = null;
var tunnel = http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('<html><head></head><body><p>listening running</p></body></html>\n');
console.log(proxySocket);
});
tunnel.on('connect',function(req,cltSocket){
console.log('connect from the client ...');
});
tunnel.listen(5000,'127.0.0.1',function(){
var proxy,
proxyOpt = {
host: "10.0.2.2",
port: 3128,
method: "CONNECT",
path: 'www.google.com:80'
},
req = http.request(proxyOpt);
req.end();
req.on('connect',function(res,_proxySocket){
proxySocket = _proxySocket;
console.log('connection established with proxy ...');
});
});
console.log('Server running at http://localhost:' + port );