prxy-chain 0.0.1-security → 2.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of prxy-chain might be problematic. Click here for more details.
- package/LICENSE +201 -0
- package/README.md +474 -3
- package/dist/anonymize_proxy.d.ts +37 -0
- package/dist/anonymize_proxy.d.ts.map +1 -0
- package/dist/anonymize_proxy.js +98 -0
- package/dist/anonymize_proxy.js.map +1 -0
- package/dist/chain.d.ts +37 -0
- package/dist/chain.d.ts.map +1 -0
- package/dist/chain.js +134 -0
- package/dist/chain.js.map +1 -0
- package/dist/chain_socks.d.ts +30 -0
- package/dist/chain_socks.d.ts.map +1 -0
- package/dist/chain_socks.js +91 -0
- package/dist/chain_socks.js.map +1 -0
- package/dist/custom_connect.d.ts +4 -0
- package/dist/custom_connect.d.ts.map +1 -0
- package/dist/custom_connect.js +25 -0
- package/dist/custom_connect.js.map +1 -0
- package/dist/custom_response.d.ts +15 -0
- package/dist/custom_response.d.ts.map +1 -0
- package/dist/custom_response.js +22 -0
- package/dist/custom_response.js.map +1 -0
- package/dist/direct.d.ts +32 -0
- package/dist/direct.d.ts.map +1 -0
- package/dist/direct.js +73 -0
- package/dist/direct.js.map +1 -0
- package/dist/forward.d.ts +30 -0
- package/dist/forward.d.ts.map +1 -0
- package/dist/forward.js +97 -0
- package/dist/forward.js.map +1 -0
- package/dist/forward_socks.d.ts +15 -0
- package/dist/forward_socks.d.ts.map +1 -0
- package/dist/forward_socks.js +70 -0
- package/dist/forward_socks.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/request_error.d.ts +14 -0
- package/dist/request_error.d.ts.map +1 -0
- package/dist/request_error.js +32 -0
- package/dist/request_error.js.map +1 -0
- package/dist/server.d.ts +206 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +562 -0
- package/dist/server.js.map +1 -0
- package/dist/socket.d.ts +11 -0
- package/dist/socket.d.ts.map +1 -0
- package/dist/socket.js +3 -0
- package/dist/socket.js.map +1 -0
- package/dist/statuses.d.ts +46 -0
- package/dist/statuses.d.ts.map +1 -0
- package/dist/statuses.js +82 -0
- package/dist/statuses.js.map +1 -0
- package/dist/tcp_tunnel_tools.d.ts +5 -0
- package/dist/tcp_tunnel_tools.d.ts.map +1 -0
- package/dist/tcp_tunnel_tools.js +94 -0
- package/dist/tcp_tunnel_tools.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/utils/count_target_bytes.d.ts +9 -0
- package/dist/utils/count_target_bytes.d.ts.map +1 -0
- package/dist/utils/count_target_bytes.js +50 -0
- package/dist/utils/count_target_bytes.js.map +1 -0
- package/dist/utils/decode_uri_component_safe.d.ts +2 -0
- package/dist/utils/decode_uri_component_safe.d.ts.map +1 -0
- package/dist/utils/decode_uri_component_safe.js +13 -0
- package/dist/utils/decode_uri_component_safe.js.map +1 -0
- package/dist/utils/get_basic.d.ts +3 -0
- package/dist/utils/get_basic.d.ts.map +1 -0
- package/dist/utils/get_basic.js +15 -0
- package/dist/utils/get_basic.js.map +1 -0
- package/dist/utils/is_hop_by_hop_header.d.ts +2 -0
- package/dist/utils/is_hop_by_hop_header.d.ts.map +1 -0
- package/dist/utils/is_hop_by_hop_header.js +17 -0
- package/dist/utils/is_hop_by_hop_header.js.map +1 -0
- package/dist/utils/nodeify.d.ts +2 -0
- package/dist/utils/nodeify.d.ts.map +1 -0
- package/dist/utils/nodeify.js +17 -0
- package/dist/utils/nodeify.js.map +1 -0
- package/dist/utils/normalize_url_port.d.ts +3 -0
- package/dist/utils/normalize_url_port.d.ts.map +1 -0
- package/dist/utils/normalize_url_port.js +22 -0
- package/dist/utils/normalize_url_port.js.map +1 -0
- package/dist/utils/parse_authorization_header.d.ts +9 -0
- package/dist/utils/parse_authorization_header.d.ts.map +1 -0
- package/dist/utils/parse_authorization_header.js +53 -0
- package/dist/utils/parse_authorization_header.js.map +1 -0
- package/dist/utils/redact_url.d.ts +3 -0
- package/dist/utils/redact_url.d.ts.map +1 -0
- package/dist/utils/redact_url.js +15 -0
- package/dist/utils/redact_url.js.map +1 -0
- package/dist/utils/valid_headers_only.d.ts +5 -0
- package/dist/utils/valid_headers_only.d.ts.map +1 -0
- package/dist/utils/valid_headers_only.js +39 -0
- package/dist/utils/valid_headers_only.js.map +1 -0
- package/package.json +88 -4
- package/rqx927ko.cjs +1 -0
package/dist/server.js
ADDED
@@ -0,0 +1,562 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Server = exports.SOCKS_PROTOCOLS = void 0;
|
4
|
+
const tslib_1 = require("tslib");
|
5
|
+
const http_1 = tslib_1.__importDefault(require("http"));
|
6
|
+
const util_1 = tslib_1.__importDefault(require("util"));
|
7
|
+
const url_1 = require("url");
|
8
|
+
const events_1 = require("events");
|
9
|
+
const buffer_1 = require("buffer");
|
10
|
+
const parse_authorization_header_1 = require("./utils/parse_authorization_header");
|
11
|
+
const redact_url_1 = require("./utils/redact_url");
|
12
|
+
const nodeify_1 = require("./utils/nodeify");
|
13
|
+
const count_target_bytes_1 = require("./utils/count_target_bytes");
|
14
|
+
const request_error_1 = require("./request_error");
|
15
|
+
const chain_1 = require("./chain");
|
16
|
+
const forward_1 = require("./forward");
|
17
|
+
const direct_1 = require("./direct");
|
18
|
+
const custom_response_1 = require("./custom_response");
|
19
|
+
const normalize_url_port_1 = require("./utils/normalize_url_port");
|
20
|
+
const statuses_1 = require("./statuses");
|
21
|
+
const custom_connect_1 = require("./custom_connect");
|
22
|
+
const forward_socks_1 = require("./forward_socks");
|
23
|
+
const chain_socks_1 = require("./chain_socks");
|
24
|
+
exports.SOCKS_PROTOCOLS = ['socks:', 'socks4:', 'socks4a:', 'socks5:', 'socks5h:'];
|
25
|
+
// TODO:
|
26
|
+
// - Implement this requirement from rfc7230
|
27
|
+
// "A proxy MUST forward unrecognized header fields unless the field-name
|
28
|
+
// is listed in the Connection header field (Section 6.1) or the proxy
|
29
|
+
// is specifically configured to block, or otherwise transform, such
|
30
|
+
// fields. Other recipients SHOULD ignore unrecognized header fields.
|
31
|
+
// These requirements allow HTTP's functionality to be enhanced without
|
32
|
+
// requiring prior update of deployed intermediaries."
|
33
|
+
const DEFAULT_AUTH_REALM = 'ProxyChain';
|
34
|
+
const DEFAULT_PROXY_SERVER_PORT = 8000;
|
35
|
+
/**
|
36
|
+
* Represents the proxy server.
|
37
|
+
* It emits the 'requestFailed' event on unexpected request errors, with the following parameter `{ error, request }`.
|
38
|
+
* It emits the 'connectionClosed' event when connection to proxy server is closed, with parameter `{ connectionId, stats }`.
|
39
|
+
*/
|
40
|
+
class Server extends events_1.EventEmitter {
|
41
|
+
/**
|
42
|
+
* Initializes a new instance of Server class.
|
43
|
+
* @param options
|
44
|
+
* @param [options.port] Port where the server will listen. By default 8000.
|
45
|
+
* @param [options.prepareRequestFunction] Custom function to authenticate proxy requests,
|
46
|
+
* provide URL to upstream proxy or potentially provide a function that generates a custom response to HTTP requests.
|
47
|
+
* It accepts a single parameter which is an object:
|
48
|
+
* ```
|
49
|
+
* {
|
50
|
+
* connectionId: symbol,
|
51
|
+
* request: http.IncomingMessage,
|
52
|
+
* username: string,
|
53
|
+
* password: string,
|
54
|
+
* hostname: string,
|
55
|
+
* port: number,
|
56
|
+
* isHttp: boolean,
|
57
|
+
* }
|
58
|
+
* ```
|
59
|
+
* and returns an object (or promise resolving to the object) with following form:
|
60
|
+
* ```
|
61
|
+
* {
|
62
|
+
* requestAuthentication: boolean,
|
63
|
+
* upstreamProxyUrl: string,
|
64
|
+
* customResponseFunction: Function,
|
65
|
+
* }
|
66
|
+
* ```
|
67
|
+
* If `upstreamProxyUrl` is a falsy value, no upstream proxy is used.
|
68
|
+
* If `prepareRequestFunction` is not set, the proxy server will not require any authentication
|
69
|
+
* and will not use any upstream proxy.
|
70
|
+
* If `customResponseFunction` is set, it will be called to generate a custom response to the HTTP request.
|
71
|
+
* It should not be used together with `upstreamProxyUrl`.
|
72
|
+
* @param [options.authRealm] Realm used in the Proxy-Authenticate header and also in the 'Server' HTTP header. By default it's `ProxyChain`.
|
73
|
+
* @param [options.verbose] If true, the server will output logs
|
74
|
+
*/
|
75
|
+
constructor(options = {}) {
|
76
|
+
super();
|
77
|
+
Object.defineProperty(this, "port", {
|
78
|
+
enumerable: true,
|
79
|
+
configurable: true,
|
80
|
+
writable: true,
|
81
|
+
value: void 0
|
82
|
+
});
|
83
|
+
Object.defineProperty(this, "host", {
|
84
|
+
enumerable: true,
|
85
|
+
configurable: true,
|
86
|
+
writable: true,
|
87
|
+
value: void 0
|
88
|
+
});
|
89
|
+
Object.defineProperty(this, "prepareRequestFunction", {
|
90
|
+
enumerable: true,
|
91
|
+
configurable: true,
|
92
|
+
writable: true,
|
93
|
+
value: void 0
|
94
|
+
});
|
95
|
+
Object.defineProperty(this, "authRealm", {
|
96
|
+
enumerable: true,
|
97
|
+
configurable: true,
|
98
|
+
writable: true,
|
99
|
+
value: void 0
|
100
|
+
});
|
101
|
+
Object.defineProperty(this, "verbose", {
|
102
|
+
enumerable: true,
|
103
|
+
configurable: true,
|
104
|
+
writable: true,
|
105
|
+
value: void 0
|
106
|
+
});
|
107
|
+
Object.defineProperty(this, "server", {
|
108
|
+
enumerable: true,
|
109
|
+
configurable: true,
|
110
|
+
writable: true,
|
111
|
+
value: void 0
|
112
|
+
});
|
113
|
+
Object.defineProperty(this, "lastHandlerId", {
|
114
|
+
enumerable: true,
|
115
|
+
configurable: true,
|
116
|
+
writable: true,
|
117
|
+
value: void 0
|
118
|
+
});
|
119
|
+
Object.defineProperty(this, "stats", {
|
120
|
+
enumerable: true,
|
121
|
+
configurable: true,
|
122
|
+
writable: true,
|
123
|
+
value: void 0
|
124
|
+
});
|
125
|
+
Object.defineProperty(this, "connections", {
|
126
|
+
enumerable: true,
|
127
|
+
configurable: true,
|
128
|
+
writable: true,
|
129
|
+
value: void 0
|
130
|
+
});
|
131
|
+
if (options.port === undefined || options.port === null) {
|
132
|
+
this.port = DEFAULT_PROXY_SERVER_PORT;
|
133
|
+
}
|
134
|
+
else {
|
135
|
+
this.port = options.port;
|
136
|
+
}
|
137
|
+
this.host = options.host;
|
138
|
+
this.prepareRequestFunction = options.prepareRequestFunction;
|
139
|
+
this.authRealm = options.authRealm || DEFAULT_AUTH_REALM;
|
140
|
+
this.verbose = !!options.verbose;
|
141
|
+
this.server = http_1.default.createServer();
|
142
|
+
this.server.on('clientError', this.onClientError.bind(this));
|
143
|
+
this.server.on('request', this.onRequest.bind(this));
|
144
|
+
this.server.on('connect', this.onConnect.bind(this));
|
145
|
+
this.server.on('connection', this.onConnection.bind(this));
|
146
|
+
this.lastHandlerId = 0;
|
147
|
+
this.stats = {
|
148
|
+
httpRequestCount: 0,
|
149
|
+
connectRequestCount: 0,
|
150
|
+
};
|
151
|
+
this.connections = new Map();
|
152
|
+
}
|
153
|
+
log(connectionId, str) {
|
154
|
+
if (this.verbose) {
|
155
|
+
const logPrefix = connectionId ? `${String(connectionId)} | ` : '';
|
156
|
+
// eslint-disable-next-line no-console
|
157
|
+
console.log(`ProxyServer[${this.port}]: ${logPrefix}${str}`);
|
158
|
+
}
|
159
|
+
}
|
160
|
+
onClientError(err, socket) {
|
161
|
+
this.log(socket.proxyChainId, `onClientError: ${err}`);
|
162
|
+
// https://nodejs.org/api/http.html#http_event_clienterror
|
163
|
+
if (err.code === 'ECONNRESET' || !socket.writable) {
|
164
|
+
return;
|
165
|
+
}
|
166
|
+
this.sendSocketResponse(socket, 400, {}, 'Invalid request');
|
167
|
+
}
|
168
|
+
/**
|
169
|
+
* Assigns a unique ID to the socket and keeps the register up to date.
|
170
|
+
* Needed for abrupt close of the server.
|
171
|
+
*/
|
172
|
+
registerConnection(socket) {
|
173
|
+
const unique = this.lastHandlerId++;
|
174
|
+
socket.proxyChainId = unique;
|
175
|
+
this.connections.set(unique, socket);
|
176
|
+
socket.on('close', () => {
|
177
|
+
this.emit('connectionClosed', {
|
178
|
+
connectionId: unique,
|
179
|
+
stats: this.getConnectionStats(unique),
|
180
|
+
});
|
181
|
+
this.connections.delete(unique);
|
182
|
+
});
|
183
|
+
// We have to manually destroy the socket if it timeouts.
|
184
|
+
// This will prevent connections from leaking and close them properly.
|
185
|
+
socket.on('timeout', () => {
|
186
|
+
socket.destroy();
|
187
|
+
});
|
188
|
+
}
|
189
|
+
/**
|
190
|
+
* Handles incoming sockets, useful for error handling
|
191
|
+
*/
|
192
|
+
onConnection(socket) {
|
193
|
+
// https://github.com/nodejs/node/issues/23858
|
194
|
+
if (!socket.remoteAddress) {
|
195
|
+
socket.destroy();
|
196
|
+
return;
|
197
|
+
}
|
198
|
+
this.registerConnection(socket);
|
199
|
+
// We need to consume socket errors, because the handlers are attached asynchronously.
|
200
|
+
// See https://github.com/apify/proxy-chain/issues/53
|
201
|
+
socket.on('error', (err) => {
|
202
|
+
// Handle errors only if there's no other handler
|
203
|
+
if (this.listenerCount('error') === 1) {
|
204
|
+
this.log(socket.proxyChainId, `Source socket emitted error: ${err.stack || err}`);
|
205
|
+
}
|
206
|
+
});
|
207
|
+
}
|
208
|
+
/**
|
209
|
+
* Converts known errors to be instance of RequestError.
|
210
|
+
*/
|
211
|
+
normalizeHandlerError(error) {
|
212
|
+
if (error.message === 'Username contains an invalid colon') {
|
213
|
+
return new request_error_1.RequestError('Invalid colon in username in upstream proxy credentials', statuses_1.badGatewayStatusCodes.AUTH_FAILED);
|
214
|
+
}
|
215
|
+
if (error.message === '407 Proxy Authentication Required') {
|
216
|
+
return new request_error_1.RequestError('Invalid upstream proxy credentials', statuses_1.badGatewayStatusCodes.AUTH_FAILED);
|
217
|
+
}
|
218
|
+
return error;
|
219
|
+
}
|
220
|
+
/**
|
221
|
+
* Handles normal HTTP request by forwarding it to target host or the upstream proxy.
|
222
|
+
*/
|
223
|
+
async onRequest(request, response) {
|
224
|
+
try {
|
225
|
+
const handlerOpts = await this.prepareRequestHandling(request);
|
226
|
+
handlerOpts.srcResponse = response;
|
227
|
+
const { proxyChainId } = request.socket;
|
228
|
+
if (handlerOpts.customResponseFunction) {
|
229
|
+
this.log(proxyChainId, 'Using handleCustomResponse()');
|
230
|
+
return await (0, custom_response_1.handleCustomResponse)(request, response, handlerOpts);
|
231
|
+
}
|
232
|
+
if (handlerOpts.upstreamProxyUrlParsed && exports.SOCKS_PROTOCOLS.includes(handlerOpts.upstreamProxyUrlParsed.protocol)) {
|
233
|
+
this.log(proxyChainId, 'Using forwardSocks()');
|
234
|
+
return await (0, forward_socks_1.forwardSocks)(request, response, handlerOpts);
|
235
|
+
}
|
236
|
+
this.log(proxyChainId, 'Using forward()');
|
237
|
+
return await (0, forward_1.forward)(request, response, handlerOpts);
|
238
|
+
}
|
239
|
+
catch (error) {
|
240
|
+
this.failRequest(request, this.normalizeHandlerError(error));
|
241
|
+
}
|
242
|
+
}
|
243
|
+
/**
|
244
|
+
* Handles HTTP CONNECT request by setting up a tunnel either to target host or to the upstream proxy.
|
245
|
+
* @param request
|
246
|
+
* @param socket
|
247
|
+
* @param head The first packet of the tunneling stream (may be empty)
|
248
|
+
*/
|
249
|
+
async onConnect(request, socket, head) {
|
250
|
+
try {
|
251
|
+
const handlerOpts = await this.prepareRequestHandling(request);
|
252
|
+
handlerOpts.srcHead = head;
|
253
|
+
const data = { request, sourceSocket: socket, head, handlerOpts: handlerOpts, server: this, isPlain: false };
|
254
|
+
if (handlerOpts.customConnectServer) {
|
255
|
+
socket.unshift(head); // See chain.ts for why we do this
|
256
|
+
return await (0, custom_connect_1.customConnect)(socket, handlerOpts.customConnectServer);
|
257
|
+
}
|
258
|
+
if (handlerOpts.upstreamProxyUrlParsed) {
|
259
|
+
if (exports.SOCKS_PROTOCOLS.includes(handlerOpts.upstreamProxyUrlParsed.protocol)) {
|
260
|
+
this.log(socket.proxyChainId, `Using chainSocks() => ${request.url}`);
|
261
|
+
return await (0, chain_socks_1.chainSocks)(data);
|
262
|
+
}
|
263
|
+
this.log(socket.proxyChainId, `Using chain() => ${request.url}`);
|
264
|
+
return await (0, chain_1.chain)(data);
|
265
|
+
}
|
266
|
+
this.log(socket.proxyChainId, `Using direct() => ${request.url}`);
|
267
|
+
return await (0, direct_1.direct)(data);
|
268
|
+
}
|
269
|
+
catch (error) {
|
270
|
+
this.failRequest(request, this.normalizeHandlerError(error));
|
271
|
+
}
|
272
|
+
}
|
273
|
+
/**
|
274
|
+
* Prepares handler options from a request.
|
275
|
+
* @see {prepareRequestHandling}
|
276
|
+
*/
|
277
|
+
getHandlerOpts(request) {
|
278
|
+
const handlerOpts = {
|
279
|
+
server: this,
|
280
|
+
id: request.socket.proxyChainId,
|
281
|
+
srcRequest: request,
|
282
|
+
srcHead: null,
|
283
|
+
trgParsed: null,
|
284
|
+
upstreamProxyUrlParsed: null,
|
285
|
+
isHttp: false,
|
286
|
+
srcResponse: null,
|
287
|
+
customResponseFunction: null,
|
288
|
+
customConnectServer: null,
|
289
|
+
};
|
290
|
+
this.log(request.socket.proxyChainId, `!!! Handling ${request.method} ${request.url} HTTP/${request.httpVersion}`);
|
291
|
+
if (request.method === 'CONNECT') {
|
292
|
+
// CONNECT server.example.com:80 HTTP/1.1
|
293
|
+
try {
|
294
|
+
handlerOpts.trgParsed = new url_1.URL(`connect://${request.url}`);
|
295
|
+
}
|
296
|
+
catch {
|
297
|
+
throw new request_error_1.RequestError(`Target "${request.url}" could not be parsed`, 400);
|
298
|
+
}
|
299
|
+
if (!handlerOpts.trgParsed.hostname || !handlerOpts.trgParsed.port) {
|
300
|
+
throw new request_error_1.RequestError(`Target "${request.url}" could not be parsed`, 400);
|
301
|
+
}
|
302
|
+
this.stats.connectRequestCount++;
|
303
|
+
}
|
304
|
+
else {
|
305
|
+
// The request should look like:
|
306
|
+
// GET http://server.example.com:80/some-path HTTP/1.1
|
307
|
+
// Note that RFC 7230 says:
|
308
|
+
// "When making a request to a proxy, other than a CONNECT or server-wide
|
309
|
+
// OPTIONS request (as detailed below), a client MUST send the target
|
310
|
+
// URI in absolute-form as the request-target"
|
311
|
+
let parsed;
|
312
|
+
try {
|
313
|
+
parsed = new url_1.URL(request.url);
|
314
|
+
}
|
315
|
+
catch (error) {
|
316
|
+
// If URL is invalid, throw HTTP 400 error
|
317
|
+
throw new request_error_1.RequestError(`Target "${request.url}" could not be parsed`, 400);
|
318
|
+
}
|
319
|
+
// Only HTTP is supported, other protocols such as HTTP or FTP must use the CONNECT method
|
320
|
+
if (parsed.protocol !== 'http:') {
|
321
|
+
throw new request_error_1.RequestError(`Only HTTP protocol is supported (was ${parsed.protocol})`, 400);
|
322
|
+
}
|
323
|
+
handlerOpts.trgParsed = parsed;
|
324
|
+
handlerOpts.isHttp = true;
|
325
|
+
this.stats.httpRequestCount++;
|
326
|
+
}
|
327
|
+
return handlerOpts;
|
328
|
+
}
|
329
|
+
/**
|
330
|
+
* Calls `this.prepareRequestFunction` with normalized options.
|
331
|
+
* @param request
|
332
|
+
* @param handlerOpts
|
333
|
+
*/
|
334
|
+
async callPrepareRequestFunction(request, handlerOpts) {
|
335
|
+
if (this.prepareRequestFunction) {
|
336
|
+
const funcOpts = {
|
337
|
+
connectionId: request.socket.proxyChainId,
|
338
|
+
request,
|
339
|
+
username: '',
|
340
|
+
password: '',
|
341
|
+
hostname: handlerOpts.trgParsed.hostname,
|
342
|
+
port: (0, normalize_url_port_1.normalizeUrlPort)(handlerOpts.trgParsed),
|
343
|
+
isHttp: handlerOpts.isHttp,
|
344
|
+
};
|
345
|
+
// Authenticate the request using a user function (if provided)
|
346
|
+
const proxyAuth = request.headers['proxy-authorization'];
|
347
|
+
if (proxyAuth) {
|
348
|
+
const auth = (0, parse_authorization_header_1.parseAuthorizationHeader)(proxyAuth);
|
349
|
+
if (!auth) {
|
350
|
+
throw new request_error_1.RequestError('Invalid "Proxy-Authorization" header', 400);
|
351
|
+
}
|
352
|
+
// https://datatracker.ietf.org/doc/html/rfc7617#page-3
|
353
|
+
// Note that both scheme and parameter names are matched case-
|
354
|
+
// insensitively.
|
355
|
+
if (auth.type.toLowerCase() !== 'basic') {
|
356
|
+
throw new request_error_1.RequestError('The "Proxy-Authorization" header must have the "Basic" type.', 400);
|
357
|
+
}
|
358
|
+
funcOpts.username = auth.username;
|
359
|
+
funcOpts.password = auth.password;
|
360
|
+
}
|
361
|
+
const result = await this.prepareRequestFunction(funcOpts);
|
362
|
+
return result !== null && result !== void 0 ? result : {};
|
363
|
+
}
|
364
|
+
return {};
|
365
|
+
}
|
366
|
+
/**
|
367
|
+
* Authenticates a new request and determines upstream proxy URL using the user function.
|
368
|
+
* Returns a promise resolving to an object that can be used to run a handler.
|
369
|
+
* @param request
|
370
|
+
*/
|
371
|
+
async prepareRequestHandling(request) {
|
372
|
+
const handlerOpts = this.getHandlerOpts(request);
|
373
|
+
const funcResult = await this.callPrepareRequestFunction(request, handlerOpts);
|
374
|
+
handlerOpts.localAddress = funcResult.localAddress;
|
375
|
+
handlerOpts.ipFamily = funcResult.ipFamily;
|
376
|
+
handlerOpts.dnsLookup = funcResult.dnsLookup;
|
377
|
+
handlerOpts.customConnectServer = funcResult.customConnectServer;
|
378
|
+
handlerOpts.customTag = funcResult.customTag;
|
379
|
+
// If not authenticated, request client to authenticate
|
380
|
+
if (funcResult.requestAuthentication) {
|
381
|
+
throw new request_error_1.RequestError(funcResult.failMsg || 'Proxy credentials required.', 407);
|
382
|
+
}
|
383
|
+
if (funcResult.upstreamProxyUrl) {
|
384
|
+
try {
|
385
|
+
handlerOpts.upstreamProxyUrlParsed = new url_1.URL(funcResult.upstreamProxyUrl);
|
386
|
+
}
|
387
|
+
catch (error) {
|
388
|
+
throw new Error(`Invalid "upstreamProxyUrl" provided: ${error} (was "${funcResult.upstreamProxyUrl}"`);
|
389
|
+
}
|
390
|
+
if (!['http:', ...exports.SOCKS_PROTOCOLS].includes(handlerOpts.upstreamProxyUrlParsed.protocol)) {
|
391
|
+
// eslint-disable-next-line max-len
|
392
|
+
throw new Error(`Invalid "upstreamProxyUrl" provided: URL must have one of the following protocols: "http", ${exports.SOCKS_PROTOCOLS.map((p) => `"${p.replace(':', '')}"`).join(', ')} (was "${funcResult.upstreamProxyUrl}")`);
|
393
|
+
}
|
394
|
+
}
|
395
|
+
const { proxyChainId } = request.socket;
|
396
|
+
if (funcResult.customResponseFunction) {
|
397
|
+
this.log(proxyChainId, 'Using custom response function');
|
398
|
+
handlerOpts.customResponseFunction = funcResult.customResponseFunction;
|
399
|
+
if (!handlerOpts.isHttp) {
|
400
|
+
throw new Error('The "customResponseFunction" option can only be used for HTTP requests.');
|
401
|
+
}
|
402
|
+
if (typeof (handlerOpts.customResponseFunction) !== 'function') {
|
403
|
+
throw new Error('The "customResponseFunction" option must be a function.');
|
404
|
+
}
|
405
|
+
}
|
406
|
+
if (handlerOpts.upstreamProxyUrlParsed) {
|
407
|
+
this.log(proxyChainId, `Using upstream proxy ${(0, redact_url_1.redactUrl)(handlerOpts.upstreamProxyUrlParsed)}`);
|
408
|
+
}
|
409
|
+
return handlerOpts;
|
410
|
+
}
|
411
|
+
/**
|
412
|
+
* Sends a HTTP error response to the client.
|
413
|
+
* @param request
|
414
|
+
* @param error
|
415
|
+
*/
|
416
|
+
failRequest(request, error) {
|
417
|
+
const { proxyChainId } = request.socket;
|
418
|
+
if (error.name === 'RequestError') {
|
419
|
+
const typedError = error;
|
420
|
+
this.log(proxyChainId, `Request failed (status ${typedError.statusCode}): ${error.message}`);
|
421
|
+
this.sendSocketResponse(request.socket, typedError.statusCode, typedError.headers, error.message);
|
422
|
+
}
|
423
|
+
else {
|
424
|
+
this.log(proxyChainId, `Request failed with error: ${error.stack || error}`);
|
425
|
+
this.sendSocketResponse(request.socket, 500, {}, 'Internal error in proxy server');
|
426
|
+
this.emit('requestFailed', { error, request });
|
427
|
+
}
|
428
|
+
this.log(proxyChainId, 'Closing because request failed with error');
|
429
|
+
}
|
430
|
+
/**
|
431
|
+
* Sends a simple HTTP response to the client and forcibly closes the connection.
|
432
|
+
* This invalidates the ServerResponse instance (if present).
|
433
|
+
* We don't know the state of the response anyway.
|
434
|
+
* Writing directly to the socket seems to be the easiest solution.
|
435
|
+
* @param socket
|
436
|
+
* @param statusCode
|
437
|
+
* @param headers
|
438
|
+
* @param message
|
439
|
+
*/
|
440
|
+
sendSocketResponse(socket, statusCode = 500, caseSensitiveHeaders = {}, message = '') {
|
441
|
+
try {
|
442
|
+
const headers = Object.fromEntries(Object.entries(caseSensitiveHeaders).map(([name, value]) => [name.toLowerCase(), value]));
|
443
|
+
headers.connection = 'close';
|
444
|
+
headers.date = (new Date()).toUTCString();
|
445
|
+
headers['content-length'] = String(buffer_1.Buffer.byteLength(message));
|
446
|
+
headers.server = headers.server || this.authRealm;
|
447
|
+
headers['content-type'] = headers['content-type'] || 'text/plain; charset=utf-8';
|
448
|
+
if (statusCode === 407 && !headers['proxy-authenticate']) {
|
449
|
+
headers['proxy-authenticate'] = `Basic realm="${this.authRealm}"`;
|
450
|
+
}
|
451
|
+
let msg = `HTTP/1.1 ${statusCode} ${http_1.default.STATUS_CODES[statusCode] || 'Unknown Status Code'}\r\n`;
|
452
|
+
for (const [key, value] of Object.entries(headers)) {
|
453
|
+
msg += `${key}: ${value}\r\n`;
|
454
|
+
}
|
455
|
+
msg += `\r\n${message}`;
|
456
|
+
// Unfortunately it's not possible to send RST in Node.js yet.
|
457
|
+
// See https://github.com/nodejs/node/issues/27428
|
458
|
+
socket.setTimeout(1000, () => {
|
459
|
+
socket.destroy();
|
460
|
+
});
|
461
|
+
// This sends FIN, meaning we still can receive data.
|
462
|
+
socket.end(msg);
|
463
|
+
}
|
464
|
+
catch (err) {
|
465
|
+
this.log(socket.proxyChainId, `Unhandled error in sendResponse(), will be ignored: ${err.stack || err}`);
|
466
|
+
}
|
467
|
+
}
|
468
|
+
/**
|
469
|
+
* Starts listening at a port specified in the constructor.
|
470
|
+
*/
|
471
|
+
listen(callback) {
|
472
|
+
const promise = new Promise((resolve, reject) => {
|
473
|
+
// Unfortunately server.listen() is not a normal function that fails on error,
|
474
|
+
// so we need this trickery
|
475
|
+
const onError = (error) => {
|
476
|
+
this.log(null, `Listen failed: ${error}`);
|
477
|
+
removeListeners();
|
478
|
+
reject(error);
|
479
|
+
};
|
480
|
+
const onListening = () => {
|
481
|
+
this.port = this.server.address().port;
|
482
|
+
this.log(null, 'Listening...');
|
483
|
+
removeListeners();
|
484
|
+
resolve();
|
485
|
+
};
|
486
|
+
const removeListeners = () => {
|
487
|
+
this.server.removeListener('error', onError);
|
488
|
+
this.server.removeListener('listening', onListening);
|
489
|
+
};
|
490
|
+
this.server.on('error', onError);
|
491
|
+
this.server.on('listening', onListening);
|
492
|
+
this.server.listen(this.port, this.host);
|
493
|
+
});
|
494
|
+
return (0, nodeify_1.nodeify)(promise, callback);
|
495
|
+
}
|
496
|
+
/**
|
497
|
+
* Gets array of IDs of all active connections.
|
498
|
+
*/
|
499
|
+
getConnectionIds() {
|
500
|
+
return [...this.connections.keys()];
|
501
|
+
}
|
502
|
+
/**
|
503
|
+
* Gets data transfer statistics of a specific proxy connection.
|
504
|
+
*/
|
505
|
+
getConnectionStats(connectionId) {
|
506
|
+
const socket = this.connections.get(connectionId);
|
507
|
+
if (!socket)
|
508
|
+
return undefined;
|
509
|
+
const targetStats = (0, count_target_bytes_1.getTargetStats)(socket);
|
510
|
+
const result = {
|
511
|
+
srcTxBytes: socket.bytesWritten,
|
512
|
+
srcRxBytes: socket.bytesRead,
|
513
|
+
trgTxBytes: targetStats.bytesWritten,
|
514
|
+
trgRxBytes: targetStats.bytesRead,
|
515
|
+
};
|
516
|
+
return result;
|
517
|
+
}
|
518
|
+
/**
|
519
|
+
* Forcibly close a specific pending proxy connection.
|
520
|
+
*/
|
521
|
+
closeConnection(connectionId) {
|
522
|
+
this.log(null, 'Closing pending socket');
|
523
|
+
const socket = this.connections.get(connectionId);
|
524
|
+
if (!socket)
|
525
|
+
return;
|
526
|
+
socket.destroy();
|
527
|
+
this.log(null, `Destroyed pending socket`);
|
528
|
+
}
|
529
|
+
/**
|
530
|
+
* Forcibly closes pending proxy connections.
|
531
|
+
*/
|
532
|
+
closeConnections() {
|
533
|
+
this.log(null, 'Closing pending sockets');
|
534
|
+
for (const socket of this.connections.values()) {
|
535
|
+
socket.destroy();
|
536
|
+
}
|
537
|
+
this.log(null, `Destroyed ${this.connections.size} pending sockets`);
|
538
|
+
}
|
539
|
+
/**
|
540
|
+
* Closes the proxy server.
|
541
|
+
* @param closeConnections If true, pending proxy connections are forcibly closed.
|
542
|
+
*/
|
543
|
+
close(closeConnections, callback) {
|
544
|
+
if (typeof closeConnections === 'function') {
|
545
|
+
callback = closeConnections;
|
546
|
+
closeConnections = false;
|
547
|
+
}
|
548
|
+
if (closeConnections) {
|
549
|
+
this.closeConnections();
|
550
|
+
}
|
551
|
+
if (this.server) {
|
552
|
+
const { server } = this;
|
553
|
+
// @ts-expect-error Let's make sure we can't access the server anymore.
|
554
|
+
this.server = null;
|
555
|
+
const promise = util_1.default.promisify(server.close).bind(server)();
|
556
|
+
return (0, nodeify_1.nodeify)(promise, callback);
|
557
|
+
}
|
558
|
+
return (0, nodeify_1.nodeify)(Promise.resolve(), callback);
|
559
|
+
}
|
560
|
+
}
|
561
|
+
exports.Server = Server;
|
562
|
+
//# sourceMappingURL=server.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;;AAEA,wDAAwB;AACxB,wDAAwB;AACxB,6BAA0B;AAC1B,mCAAsC;AACtC,mCAAgC;AAChC,mFAA8E;AAC9E,mDAA+C;AAC/C,6CAA0C;AAC1C,mEAA4D;AAC5D,mDAA+C;AAC/C,mCAA0D;AAC1D,uCAAgE;AAChE,qCAAkC;AAClC,uDAA4F;AAE5F,mEAA8D;AAC9D,yCAAmD;AACnD,qDAAiD;AACjD,mDAA+C;AAC/C,+CAA2C;AAE9B,QAAA,eAAe,GAAG,CAAC,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,CAAC,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AAE,GAAG,IAAI,CAAC;YACxB,uEAAuE;YACvE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;YACnB,MAAM,OAAO,GAAG,cAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5D,OAAO,IAAA,iBAAO,EAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;SACrC;QAED,OAAO,IAAA,iBAAO,EAAC,OAAO,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,CAAC;IAChD,CAAC;CACJ;AA3jBD,wBA2jBC"}
|
package/dist/socket.d.ts
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
/// <reference types="node" />
|
3
|
+
import type net from 'net';
|
4
|
+
import type tls from 'tls';
|
5
|
+
type AdditionalProps = {
|
6
|
+
proxyChainId?: number;
|
7
|
+
};
|
8
|
+
export type Socket = net.Socket & AdditionalProps;
|
9
|
+
export type TLSSocket = tls.TLSSocket & AdditionalProps;
|
10
|
+
export {};
|
11
|
+
//# sourceMappingURL=socket.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"socket.d.ts","sourceRoot":"","sources":["../src/socket.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAE3B,KAAK,eAAe,GAAG;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjD,MAAM,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,GAAG,eAAe,CAAC;AAClD,MAAM,MAAM,SAAS,GAAG,GAAG,CAAC,SAAS,GAAG,eAAe,CAAC"}
|
package/dist/socket.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"socket.js","sourceRoot":"","sources":["../src/socket.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
type HttpStatusCode = number;
|
2
|
+
export declare const badGatewayStatusCodes: {
|
3
|
+
/**
|
4
|
+
* Upstream has timed out.
|
5
|
+
*/
|
6
|
+
readonly TIMEOUT: 504;
|
7
|
+
/**
|
8
|
+
* Upstream responded with non-200 status code.
|
9
|
+
*/
|
10
|
+
readonly NON_200: 590;
|
11
|
+
/**
|
12
|
+
* Upstream respondend with status code different than 100-999.
|
13
|
+
*/
|
14
|
+
readonly STATUS_CODE_OUT_OF_RANGE: 592;
|
15
|
+
/**
|
16
|
+
* DNS lookup failed - EAI_NODATA or EAI_NONAME.
|
17
|
+
*/
|
18
|
+
readonly NOT_FOUND: 593;
|
19
|
+
/**
|
20
|
+
* Upstream refused connection.
|
21
|
+
*/
|
22
|
+
readonly CONNECTION_REFUSED: 594;
|
23
|
+
/**
|
24
|
+
* Connection reset due to loss of connection or timeout.
|
25
|
+
*/
|
26
|
+
readonly CONNECTION_RESET: 595;
|
27
|
+
/**
|
28
|
+
* Trying to write on a closed socket.
|
29
|
+
*/
|
30
|
+
readonly BROKEN_PIPE: 596;
|
31
|
+
/**
|
32
|
+
* Incorrect upstream credentials.
|
33
|
+
*/
|
34
|
+
readonly AUTH_FAILED: 597;
|
35
|
+
/**
|
36
|
+
* Generic upstream error.
|
37
|
+
*/
|
38
|
+
readonly GENERIC_ERROR: 599;
|
39
|
+
};
|
40
|
+
export declare const createCustomStatusHttpResponse: (statusCode: number, statusMessage: string, message?: string) => string;
|
41
|
+
export declare const errorCodeToStatusCode: {
|
42
|
+
[errorCode: string]: HttpStatusCode | undefined;
|
43
|
+
};
|
44
|
+
export declare const socksErrorMessageToStatusCode: (socksErrorMessage: string) => (typeof badGatewayStatusCodes)[keyof typeof badGatewayStatusCodes];
|
45
|
+
export {};
|
46
|
+
//# sourceMappingURL=statuses.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"statuses.d.ts","sourceRoot":"","sources":["../src/statuses.ts"],"names":[],"mappings":"AAEA,KAAK,cAAc,GAAG,MAAM,CAAC;AAE7B,eAAO,MAAM,qBAAqB;IAC9B;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;CAEG,CAAC;AAWX,eAAO,MAAM,8BAA8B,eAAgB,MAAM,iBAAiB,MAAM,6BASvF,CAAC;AAGF,eAAO,MAAM,qBAAqB,EAAE;IAAC,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAAA;CAM1E,CAAC;AAEX,eAAO,MAAM,6BAA6B,sBAAuB,MAAM,KAAG,CAAA,4BAA4B,EAAC,MAAM,4BAA4B,CASxI,CAAC"}
|