-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmiddle.js
More file actions
39 lines (34 loc) · 1006 Bytes
/
middle.js
File metadata and controls
39 lines (34 loc) · 1006 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
33
34
35
36
37
38
39
var net = require('net');
var tls = require('tls');
var fs = require('fs');
const HOST = '127.0.0.1';
const PORT = 5050;
var LHOST = '127.0.0.1';
var LPORT = 12346;
var cert = fs.readFileSync('cert.pem');
//process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
net.createServer(function(sock){
var client = tls.connect({
host:HOST,
port:PORT,
cert:cert,
servername:'NiceProxy.org',
rejectUnauthorized:false,
secureOptions:tls.SSL_OP_NO_SSLv2 | tls.SSL_OP_NO_SSLv3
}, function(){});
client.on('data', function(data) {
sock.write(data);
});
// 为客户端添加“close”事件处理函数
client.on('close', function() {
sock.destroy();
});
//client.on('error',(e)=>{console.log(e)});
sock.on('data', function(data){
client.write(data);
});
sock.on('close', function(data) {
client.destroy()
});
}).listen(LPORT, LHOST);
console.log('Server listening on ' + LHOST +':'+ LPORT);