-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathProxyServer.js
48 lines (39 loc) · 1.42 KB
/
ProxyServer.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
39
40
41
42
43
44
45
46
47
48
const net = require('net');
const onConnectedClientHandling = require('./core/onConnectedClientHandling');
const Logger = require('./lib/Logger');
const {DEFAULT_OPTIONS} = require('./lib/constants');
class ProxyServer extends net.createServer {
constructor(options) {
const {
upstream, tcpOutgoingAddress,
verbose,
injectData, injectResponse,
auth, intercept, keys,
handleSni, logger,
interceptOptions
} = Object.assign({}, DEFAULT_OPTIONS, options); //merging with default options
const bridgedConnections = {};
super(function (clientSocket) {
onConnectedClientHandling(
clientSocket,
bridgedConnections,
{
upstream, tcpOutgoingAddress,
injectData, injectResponse,
auth, intercept, keys,
handleSni, interceptOptions
},
logger || new Logger(verbose));
});
this.bridgedConnections = bridgedConnections;
//TODO this is an horrible workaround, but extending doesn't work
this.getBridgedConnections = function _getBridgedConnections() {
return this.bridgedConnections;
}
}
//TODO why doesnt work?
getBridgedConnections() {
return this.bridgedConnections;
};
}
module.exports = ProxyServer;