forked from gr3p1p3/transparent-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProxyServer.js
41 lines (33 loc) · 1.14 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
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
} = {...DEFAULT_OPTIONS, ...options}; //merging with default options
const bridgedConnections = {};
super(function (clientSocket) {
onConnectedClientHandling(
clientSocket,
bridgedConnections,
{
upstream, tcpOutgoingAddress,
injectData, injectResponse,
auth, intercept, keys,
handleSni,
},
logger || new Logger(verbose) )
});
this.bridgedConnections = bridgedConnections;
}
getBridgedConnections() {
return this.bridgedConnections;
};
}
module.exports = ProxyServer;