proxy-chain 2.7.1 → 3.0.0-beta.1
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.
- package/README.md +53 -62
- package/dist/anonymize_proxy.d.ts +2 -6
- package/dist/anonymize_proxy.d.ts.map +1 -1
- package/dist/anonymize_proxy.js +27 -44
- package/dist/anonymize_proxy.js.map +1 -1
- package/dist/chain.d.ts +1 -8
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +15 -21
- package/dist/chain.js.map +1 -1
- package/dist/chain_socks.d.ts +1 -6
- package/dist/chain_socks.d.ts.map +1 -1
- package/dist/chain_socks.js +9 -13
- package/dist/chain_socks.js.map +1 -1
- package/dist/custom_connect.d.ts.map +1 -1
- package/dist/custom_connect.js +3 -7
- package/dist/custom_connect.js.map +1 -1
- package/dist/custom_response.d.ts +0 -2
- package/dist/custom_response.d.ts.map +1 -1
- package/dist/custom_response.js +1 -5
- package/dist/custom_response.js.map +1 -1
- package/dist/direct.d.ts +1 -5
- package/dist/direct.d.ts.map +1 -1
- package/dist/direct.js +7 -12
- package/dist/direct.js.map +1 -1
- package/dist/forward.d.ts +0 -4
- package/dist/forward.d.ts.map +1 -1
- package/dist/forward.js +17 -25
- package/dist/forward.js.map +1 -1
- package/dist/forward_socks.d.ts +0 -1
- package/dist/forward_socks.d.ts.map +1 -1
- package/dist/forward_socks.js +15 -23
- package/dist/forward_socks.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -8
- package/dist/index.js.map +1 -1
- package/dist/request_error.d.ts.map +1 -1
- package/dist/request_error.js +5 -17
- package/dist/request_error.js.map +1 -1
- package/dist/server.d.ts +4 -12
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +68 -133
- package/dist/server.js.map +1 -1
- package/dist/socket.d.ts +0 -2
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +1 -2
- package/dist/statuses.d.ts.map +1 -1
- package/dist/statuses.js +22 -27
- package/dist/statuses.js.map +1 -1
- package/dist/tcp_tunnel_tools.d.ts +2 -2
- package/dist/tcp_tunnel_tools.d.ts.map +1 -1
- package/dist/tcp_tunnel_tools.js +23 -41
- package/dist/tcp_tunnel_tools.js.map +1 -1
- package/dist/utils/count_target_bytes.d.ts +2 -3
- package/dist/utils/count_target_bytes.d.ts.map +1 -1
- package/dist/utils/count_target_bytes.js +4 -12
- package/dist/utils/count_target_bytes.js.map +1 -1
- package/dist/utils/decode_uri_component_safe.d.ts.map +1 -1
- package/dist/utils/decode_uri_component_safe.js +1 -5
- package/dist/utils/decode_uri_component_safe.js.map +1 -1
- package/dist/utils/get_basic.d.ts.map +1 -1
- package/dist/utils/get_basic.js +4 -8
- package/dist/utils/get_basic.js.map +1 -1
- package/dist/utils/is_hop_by_hop_header.d.ts.map +1 -1
- package/dist/utils/is_hop_by_hop_header.js +1 -5
- package/dist/utils/is_hop_by_hop_header.js.map +1 -1
- package/dist/utils/normalize_url_port.d.ts.map +1 -1
- package/dist/utils/normalize_url_port.js +1 -5
- package/dist/utils/normalize_url_port.js.map +1 -1
- package/dist/utils/parse_authorization_header.d.ts.map +1 -1
- package/dist/utils/parse_authorization_header.js +3 -7
- package/dist/utils/parse_authorization_header.js.map +1 -1
- package/dist/utils/redact_url.d.ts.map +1 -1
- package/dist/utils/redact_url.js +3 -7
- package/dist/utils/redact_url.js.map +1 -1
- package/dist/utils/valid_headers_only.d.ts.map +1 -1
- package/dist/utils/valid_headers_only.js +6 -10
- package/dist/utils/valid_headers_only.js.map +1 -1
- package/package.json +102 -93
- package/dist/utils/nodeify.d.ts +0 -2
- package/dist/utils/nodeify.d.ts.map +0 -1
- package/dist/utils/nodeify.js +0 -17
- package/dist/utils/nodeify.js.map +0 -1
package/README.md
CHANGED
|
@@ -21,21 +21,20 @@ The proxy-chain package currently supports HTTP/SOCKS forwarding and HTTP CONNEC
|
|
|
21
21
|
## Run a simple HTTP/HTTPS proxy server
|
|
22
22
|
|
|
23
23
|
```javascript
|
|
24
|
-
|
|
24
|
+
import { Server } from 'proxy-chain';
|
|
25
25
|
|
|
26
|
-
const server = new
|
|
26
|
+
const server = new Server({ port: 8000 });
|
|
27
27
|
|
|
28
|
-
server.listen(
|
|
29
|
-
|
|
30
|
-
});
|
|
28
|
+
await server.listen();
|
|
29
|
+
console.log(`Proxy server is listening on port ${server.port}`);
|
|
31
30
|
```
|
|
32
31
|
|
|
33
32
|
## Run a HTTP/HTTPS proxy server with credentials and upstream proxy
|
|
34
33
|
|
|
35
34
|
```javascript
|
|
36
|
-
|
|
35
|
+
import { Server } from 'proxy-chain';
|
|
37
36
|
|
|
38
|
-
const server = new
|
|
37
|
+
const server = new Server({
|
|
39
38
|
// Port where the server will listen. By default 8000.
|
|
40
39
|
port: 8000,
|
|
41
40
|
|
|
@@ -93,10 +92,6 @@ const server = new ProxyChain.Server({
|
|
|
93
92
|
},
|
|
94
93
|
});
|
|
95
94
|
|
|
96
|
-
server.listen(() => {
|
|
97
|
-
console.log(`Proxy server is listening on port ${server.port}`);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
95
|
// Emitted when HTTP connection is closed
|
|
101
96
|
server.on('connectionClosed', ({ connectionId, stats }) => {
|
|
102
97
|
console.log(`Connection ${connectionId} closed`);
|
|
@@ -108,6 +103,9 @@ server.on('requestFailed', ({ request, error }) => {
|
|
|
108
103
|
console.log(`Request ${request.url} failed`);
|
|
109
104
|
console.error(error);
|
|
110
105
|
});
|
|
106
|
+
|
|
107
|
+
await server.listen();
|
|
108
|
+
console.log(`Proxy server is listening on port ${server.port}`);
|
|
111
109
|
```
|
|
112
110
|
|
|
113
111
|
## Run a simple HTTPS proxy server
|
|
@@ -115,16 +113,16 @@ server.on('requestFailed', ({ request, error }) => {
|
|
|
115
113
|
This example demonstrates how to create an HTTPS proxy server with a self-signed certificate. The HTTPS proxy server works identically to the HTTP version but with TLS encryption.
|
|
116
114
|
|
|
117
115
|
```javascript
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
116
|
+
import { Server } from 'proxy-chain';
|
|
117
|
+
import fs from 'node:fs';
|
|
118
|
+
import path from 'node:path';
|
|
121
119
|
|
|
122
120
|
(async () => {
|
|
123
121
|
// TODO: update these lines to use your own key and cert
|
|
124
|
-
const sslKey = fs.readFileSync(path.join(
|
|
125
|
-
const sslCrt = fs.readFileSync(path.join(
|
|
122
|
+
const sslKey = fs.readFileSync(path.join(import.meta.dirname, 'ssl.key'));
|
|
123
|
+
const sslCrt = fs.readFileSync(path.join(import.meta.dirname, 'ssl.crt'));
|
|
126
124
|
|
|
127
|
-
const server = new
|
|
125
|
+
const server = new Server({
|
|
128
126
|
// Main difference between 'http' and 'https' is additional event listening:
|
|
129
127
|
//
|
|
130
128
|
// http
|
|
@@ -208,9 +206,9 @@ curl --proxy-insecure -x https://localhost:8443 -k https://example.com
|
|
|
208
206
|
You can provide custom HTTP/HTTPS agents to enable connection pooling and reuse with upstream proxies. This is particularly useful for maintaining sticky IP addresses or reducing connection overhead:
|
|
209
207
|
|
|
210
208
|
```javascript
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
209
|
+
import http from 'node:http';
|
|
210
|
+
import https from 'node:https';
|
|
211
|
+
import { Server } from 'proxy-chain';
|
|
214
212
|
|
|
215
213
|
// Create agents with keepAlive to enable connection pooling
|
|
216
214
|
const httpAgent = new http.Agent({
|
|
@@ -223,7 +221,7 @@ const httpsAgent = new https.Agent({
|
|
|
223
221
|
maxSockets: 10,
|
|
224
222
|
});
|
|
225
223
|
|
|
226
|
-
const server = new
|
|
224
|
+
const server = new Server({
|
|
227
225
|
port: 8000,
|
|
228
226
|
prepareRequestFunction: ({ request }) => {
|
|
229
227
|
return {
|
|
@@ -237,9 +235,8 @@ const server = new ProxyChain.Server({
|
|
|
237
235
|
},
|
|
238
236
|
});
|
|
239
237
|
|
|
240
|
-
server.listen(
|
|
241
|
-
|
|
242
|
-
});
|
|
238
|
+
await server.listen();
|
|
239
|
+
console.log(`Proxy server is listening on port ${server.port}`);
|
|
243
240
|
```
|
|
244
241
|
|
|
245
242
|
**Note:** Custom agents are only supported for HTTP and HTTPS upstream proxies. SOCKS upstream proxies use direct socket connections and do not support custom agents.
|
|
@@ -309,12 +306,12 @@ The class constructor has the following parameters: `RequestError(body, statusCo
|
|
|
309
306
|
By default, the response will have `Content-Type: text/plain; charset=utf-8`.
|
|
310
307
|
|
|
311
308
|
```javascript
|
|
312
|
-
|
|
309
|
+
import { Server, RequestError } from 'proxy-chain';
|
|
313
310
|
|
|
314
|
-
const server = new
|
|
311
|
+
const server = new Server({
|
|
315
312
|
prepareRequestFunction: ({ request, username, password, hostname, port, isHttp, connectionId }) => {
|
|
316
313
|
if (username !== 'bob') {
|
|
317
|
-
throw new
|
|
314
|
+
throw new RequestError('Only Bob can use this proxy!', 400);
|
|
318
315
|
}
|
|
319
316
|
},
|
|
320
317
|
});
|
|
@@ -379,9 +376,9 @@ with the following properties:
|
|
|
379
376
|
Here is a simple example:
|
|
380
377
|
|
|
381
378
|
```javascript
|
|
382
|
-
|
|
379
|
+
import { Server } from 'proxy-chain';
|
|
383
380
|
|
|
384
|
-
const server = new
|
|
381
|
+
const server = new Server({
|
|
385
382
|
port: 8000,
|
|
386
383
|
prepareRequestFunction: ({ request, username, password, hostname, port, isHttp }) => {
|
|
387
384
|
return {
|
|
@@ -395,9 +392,8 @@ const server = new ProxyChain.Server({
|
|
|
395
392
|
},
|
|
396
393
|
});
|
|
397
394
|
|
|
398
|
-
server.listen(
|
|
399
|
-
|
|
400
|
-
});
|
|
395
|
+
await server.listen();
|
|
396
|
+
console.log(`Proxy server is listening on port ${server.port}`);
|
|
401
397
|
```
|
|
402
398
|
|
|
403
399
|
## Routing CONNECT to another HTTP server
|
|
@@ -406,14 +402,14 @@ While `customResponseFunction` enables custom handling methods such as `GET` and
|
|
|
406
402
|
It's possible to route those requests differently using the `customConnectServer` option. It accepts an instance of Node.js HTTP server.
|
|
407
403
|
|
|
408
404
|
```javascript
|
|
409
|
-
|
|
410
|
-
|
|
405
|
+
import http from 'node:http';
|
|
406
|
+
import { Server } from 'proxy-chain';
|
|
411
407
|
|
|
412
408
|
const exampleServer = http.createServer((request, response) => {
|
|
413
409
|
response.end('Hello from a custom server!');
|
|
414
410
|
});
|
|
415
411
|
|
|
416
|
-
const server = new
|
|
412
|
+
const server = new Server({
|
|
417
413
|
port: 8000,
|
|
418
414
|
prepareRequestFunction: ({ request, username, password, hostname, port, isHttp }) => {
|
|
419
415
|
if (request.url.toLowerCase() === 'example.com:80') {
|
|
@@ -426,9 +422,8 @@ const server = new ProxyChain.Server({
|
|
|
426
422
|
},
|
|
427
423
|
});
|
|
428
424
|
|
|
429
|
-
server.listen(
|
|
430
|
-
|
|
431
|
-
});
|
|
425
|
+
await server.listen();
|
|
426
|
+
console.log(`Proxy server is listening on port ${server.port}`);
|
|
432
427
|
```
|
|
433
428
|
|
|
434
429
|
In the example above, all CONNECT tunnels to `example.com` are overridden.
|
|
@@ -437,8 +432,9 @@ This is an unsecure server, so it accepts only `http:` requests.
|
|
|
437
432
|
In order to intercept `https:` requests, `https.createServer` should be used instead, along with a self signed certificate.
|
|
438
433
|
|
|
439
434
|
```javascript
|
|
440
|
-
|
|
441
|
-
|
|
435
|
+
import https from 'node:https';
|
|
436
|
+
import fs from 'node:fs';
|
|
437
|
+
|
|
442
438
|
const key = fs.readFileSync('./test/ssl.key');
|
|
443
439
|
const cert = fs.readFileSync('./test/ssl.crt');
|
|
444
440
|
|
|
@@ -452,17 +448,16 @@ const exampleServer = https.createServer({
|
|
|
452
448
|
|
|
453
449
|
## Closing the server
|
|
454
450
|
|
|
455
|
-
To shut down the proxy server, call the `close([destroyConnections]
|
|
451
|
+
To shut down the proxy server, call the `close([destroyConnections])` function. For example:
|
|
456
452
|
|
|
457
453
|
```javascript
|
|
458
|
-
server.close(true
|
|
459
|
-
|
|
460
|
-
});
|
|
454
|
+
await server.close(true);
|
|
455
|
+
console.log('Proxy server was closed.');
|
|
461
456
|
```
|
|
462
457
|
|
|
463
458
|
The `closeConnections` parameter indicates whether pending proxy connections should be forcibly closed.
|
|
464
459
|
If it's `false`, the function will wait until all connections are closed, which can take a long time.
|
|
465
|
-
|
|
460
|
+
The function returns a promise.
|
|
466
461
|
|
|
467
462
|
|
|
468
463
|
## Accessing the CONNECT response headers for proxy tunneling
|
|
@@ -504,7 +499,7 @@ server.on('tunnelConnectFailed', ({ proxyChainId, response, socket, head, custom
|
|
|
504
499
|
The package also provides several utility functions.
|
|
505
500
|
|
|
506
501
|
|
|
507
|
-
### `anonymizeProxy({ url, port }
|
|
502
|
+
### `anonymizeProxy({ url, port })`
|
|
508
503
|
|
|
509
504
|
Parses and validates a HTTP/HTTPS proxy URL. If the proxy requires authentication,
|
|
510
505
|
then the function starts an open local proxy server that forwards to the proxy.
|
|
@@ -513,21 +508,20 @@ The port (on which the local proxy server will start) can be set via the `port`
|
|
|
513
508
|
For HTTPS proxy with self-signed certificate, set `ignoreProxyCertificate` property of the first argument to `true` to ignore certificate errors in
|
|
514
509
|
proxy requests.
|
|
515
510
|
|
|
516
|
-
The function
|
|
517
|
-
|
|
518
|
-
anonymous proxy URL or the original URL if it was already anonymous.
|
|
511
|
+
The function returns a promise that resolves to a String with the anonymous proxy URL,
|
|
512
|
+
or the original URL if it was already anonymous.
|
|
519
513
|
|
|
520
514
|
The following example shows how you can use a proxy with authentication
|
|
521
515
|
from headless Chrome and [Puppeteer](https://github.com/GoogleChrome/puppeteer).
|
|
522
516
|
For details, read this [blog post](https://blog.apify.com/how-to-make-headless-chrome-and-puppeteer-use-a-proxy-server-with-authentication-249a21a79212).
|
|
523
517
|
|
|
524
518
|
```javascript
|
|
525
|
-
|
|
526
|
-
|
|
519
|
+
import puppeteer from 'puppeteer';
|
|
520
|
+
import { anonymizeProxy, closeAnonymizedProxy } from 'proxy-chain';
|
|
527
521
|
|
|
528
522
|
(async() => {
|
|
529
523
|
const oldProxyUrl = 'http://bob:password123@proxy.example.com:8000';
|
|
530
|
-
const newProxyUrl = await
|
|
524
|
+
const newProxyUrl = await anonymizeProxy(oldProxyUrl);
|
|
531
525
|
|
|
532
526
|
// Prints something like "http://127.0.0.1:45678"
|
|
533
527
|
console.log(newProxyUrl);
|
|
@@ -543,11 +537,11 @@ const proxyChain = require('proxy-chain');
|
|
|
543
537
|
await browser.close();
|
|
544
538
|
|
|
545
539
|
// Clean up
|
|
546
|
-
await
|
|
540
|
+
await closeAnonymizedProxy(newProxyUrl, true);
|
|
547
541
|
})();
|
|
548
542
|
```
|
|
549
543
|
|
|
550
|
-
### `closeAnonymizedProxy(anonymizedProxyUrl, closeConnections
|
|
544
|
+
### `closeAnonymizedProxy(anonymizedProxyUrl, closeConnections)`
|
|
551
545
|
|
|
552
546
|
Closes anonymous proxy previously started by `anonymizeProxy()`.
|
|
553
547
|
If proxy was not found or was already closed, the function has no effect
|
|
@@ -556,10 +550,9 @@ and its result is `false`. Otherwise the result is `true`.
|
|
|
556
550
|
The `closeConnections` parameter indicates whether pending proxy connections are forcibly closed.
|
|
557
551
|
If it's `false`, the function will wait until all connections are closed, which can take a long time.
|
|
558
552
|
|
|
559
|
-
The function
|
|
560
|
-
If callback is not provided, the function returns a promise instead.
|
|
553
|
+
The function returns a promise that resolves to a Boolean.
|
|
561
554
|
|
|
562
|
-
### `createTunnel(proxyUrl, targetHost, options
|
|
555
|
+
### `createTunnel(proxyUrl, targetHost, options)`
|
|
563
556
|
|
|
564
557
|
Creates a TCP tunnel to `targetHost` that goes through a HTTP/HTTPS proxy server
|
|
565
558
|
specified by the `proxyUrl` parameter.
|
|
@@ -577,8 +570,7 @@ For example, this is useful if you want to access a certain service from a speci
|
|
|
577
570
|
|
|
578
571
|
The tunnel should be eventually closed by calling the `closeTunnel()` function.
|
|
579
572
|
|
|
580
|
-
The `createTunnel()` function
|
|
581
|
-
If no callback is supplied, the function returns a promise that resolves to a String with
|
|
573
|
+
The `createTunnel()` function returns a promise that resolves to a String with
|
|
582
574
|
the path to the local endpoint.
|
|
583
575
|
|
|
584
576
|
For more information, read this [blog post](https://blog.apify.com/tunneling-arbitrary-protocols-over-http-proxy-with-static-ip-address-b3a2222191ff).
|
|
@@ -591,7 +583,7 @@ const host = await createTunnel('http://bob:pass123@proxy.example.com:8000', 'se
|
|
|
591
583
|
console.log(host);
|
|
592
584
|
```
|
|
593
585
|
|
|
594
|
-
### `closeTunnel(tunnelString, closeConnections
|
|
586
|
+
### `closeTunnel(tunnelString, closeConnections)`
|
|
595
587
|
|
|
596
588
|
Closes tunnel previously started by `createTunnel()`.
|
|
597
589
|
The result value is `false` if the tunnel was not found or was already closed, otherwise it is `true`.
|
|
@@ -599,8 +591,7 @@ The result value is `false` if the tunnel was not found or was already closed, o
|
|
|
599
591
|
The `closeConnections` parameter indicates whether pending connections are forcibly closed.
|
|
600
592
|
If it's `false`, the function will wait until all connections are closed, which can take a long time.
|
|
601
593
|
|
|
602
|
-
The function
|
|
603
|
-
If the callback is not provided, the function returns a promise instead.
|
|
594
|
+
The function returns a promise that resolves to a Boolean.
|
|
604
595
|
|
|
605
596
|
### `listenConnectAnonymizedProxy(anonymizedProxyUrl, tunnelConnectRespondedCallback)`
|
|
606
597
|
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
/// <reference types="node" />
|
|
4
|
-
/// <reference types="node" />
|
|
5
1
|
import type { Buffer } from 'node:buffer';
|
|
6
2
|
import type http from 'node:http';
|
|
7
3
|
import type net from 'node:net';
|
|
@@ -15,14 +11,14 @@ export interface AnonymizeProxyOptions {
|
|
|
15
11
|
* or if it is an HTTPS proxy and `ignoreProxyCertificate` is `true`, then the function
|
|
16
12
|
* starts an open local proxy server that forwards to the upstream proxy.
|
|
17
13
|
*/
|
|
18
|
-
export declare const anonymizeProxy: (options: string | AnonymizeProxyOptions
|
|
14
|
+
export declare const anonymizeProxy: (options: string | AnonymizeProxyOptions) => Promise<string>;
|
|
19
15
|
/**
|
|
20
16
|
* Closes anonymous proxy previously started by `anonymizeProxy()`.
|
|
21
17
|
* If proxy was not found or was already closed, the function has no effect
|
|
22
18
|
* and its result if `false`. Otherwise the result is `true`.
|
|
23
19
|
* @param closeConnections If true, pending proxy connections are forcibly closed.
|
|
24
20
|
*/
|
|
25
|
-
export declare const closeAnonymizedProxy: (anonymizedProxyUrl: string, closeConnections: boolean
|
|
21
|
+
export declare const closeAnonymizedProxy: (anonymizedProxyUrl: string, closeConnections: boolean) => Promise<boolean>;
|
|
26
22
|
type Callback = ({ response, socket, head, }: {
|
|
27
23
|
response: http.IncomingMessage;
|
|
28
24
|
socket: net.Socket;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anonymize_proxy.d.ts","sourceRoot":"","sources":["../src/anonymize_proxy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"anonymize_proxy.d.ts","sourceRoot":"","sources":["../src/anonymize_proxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAQhC,MAAM,WAAW,qBAAqB;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,sBAAsB,CAAC,EAAE,OAAO,CAAC;CACpC;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,GACvB,SAAS,MAAM,GAAG,qBAAqB,KACxC,OAAO,CAAC,MAAM,CAkDhB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAC7B,oBAAoB,MAAM,EAC1B,kBAAkB,OAAO,KAC1B,OAAO,CAAC,OAAO,CAcjB,CAAC;AAEF,KAAK,QAAQ,GAAG,CAAC,EACb,QAAQ,EACR,MAAM,EACN,IAAI,GACP,EAAE;IACC,QAAQ,EAAE,IAAI,CAAC,eAAe,CAAC;IAC/B,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CAChB,KAAK,IAAI,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,GACrC,oBAAoB,MAAM,EAC1B,gCAAgC,QAAQ,KACzC,OASF,CAAC"}
|
package/dist/anonymize_proxy.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.listenConnectAnonymizedProxy = exports.closeAnonymizedProxy = exports.anonymizeProxy = void 0;
|
|
4
|
-
const node_url_1 = require("node:url");
|
|
5
|
-
const server_1 = require("./server");
|
|
6
|
-
const nodeify_1 = require("./utils/nodeify");
|
|
1
|
+
import { URL } from 'node:url';
|
|
2
|
+
import { Server, SOCKS_PROTOCOLS } from './server.js';
|
|
7
3
|
// Dictionary, key is value returned from anonymizeProxy(), value is Server instance.
|
|
8
4
|
const anonymizedProxyUrlToServer = {};
|
|
9
5
|
/**
|
|
@@ -11,7 +7,7 @@ const anonymizedProxyUrlToServer = {};
|
|
|
11
7
|
* or if it is an HTTPS proxy and `ignoreProxyCertificate` is `true`, then the function
|
|
12
8
|
* starts an open local proxy server that forwards to the upstream proxy.
|
|
13
9
|
*/
|
|
14
|
-
const anonymizeProxy = async (options
|
|
10
|
+
export const anonymizeProxy = async (options) => {
|
|
15
11
|
let proxyUrl;
|
|
16
12
|
let port = 0;
|
|
17
13
|
let ignoreProxyCertificate = false;
|
|
@@ -28,68 +24,56 @@ const anonymizeProxy = async (options, callback) => {
|
|
|
28
24
|
ignoreProxyCertificate = options.ignoreProxyCertificate;
|
|
29
25
|
}
|
|
30
26
|
}
|
|
31
|
-
const parsedProxyUrl = new
|
|
32
|
-
if (!['http:', 'https:', ...
|
|
33
|
-
throw new Error(`Invalid "proxyUrl" provided: URL must have one of the following protocols: "http", "https", ${
|
|
27
|
+
const parsedProxyUrl = new URL(proxyUrl);
|
|
28
|
+
if (!['http:', 'https:', ...SOCKS_PROTOCOLS].includes(parsedProxyUrl.protocol)) {
|
|
29
|
+
throw new Error(`Invalid "proxyUrl" provided: URL must have one of the following protocols: "http", "https", ${SOCKS_PROTOCOLS.map((p) => `"${p.replace(':', '')}"`).join(', ')} (was "${parsedProxyUrl}")`);
|
|
34
30
|
}
|
|
35
31
|
// If upstream proxy requires no password or if there is no need to ignore HTTPS proxy cert errors, return it directly
|
|
36
32
|
if (!parsedProxyUrl.username && !parsedProxyUrl.password && (!ignoreProxyCertificate || parsedProxyUrl.protocol !== 'https:')) {
|
|
37
|
-
return
|
|
33
|
+
return proxyUrl;
|
|
38
34
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
ignoreUpstreamProxyCertificate: ignoreProxyCertificate,
|
|
51
|
-
};
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
return server.listen();
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
const promise = startServer().then(() => {
|
|
58
|
-
const url = `http://127.0.0.1:${server.port}`;
|
|
59
|
-
anonymizedProxyUrlToServer[url] = server;
|
|
60
|
-
return url;
|
|
35
|
+
const server = new Server({
|
|
36
|
+
// verbose: true,
|
|
37
|
+
port,
|
|
38
|
+
host: '127.0.0.1',
|
|
39
|
+
prepareRequestFunction: () => {
|
|
40
|
+
return {
|
|
41
|
+
requestAuthentication: false,
|
|
42
|
+
upstreamProxyUrl: proxyUrl,
|
|
43
|
+
ignoreUpstreamProxyCertificate: ignoreProxyCertificate,
|
|
44
|
+
};
|
|
45
|
+
},
|
|
61
46
|
});
|
|
62
|
-
|
|
47
|
+
await server.listen();
|
|
48
|
+
const url = `http://127.0.0.1:${server.port}`;
|
|
49
|
+
anonymizedProxyUrlToServer[url] = server;
|
|
50
|
+
return url;
|
|
63
51
|
};
|
|
64
|
-
exports.anonymizeProxy = anonymizeProxy;
|
|
65
52
|
/**
|
|
66
53
|
* Closes anonymous proxy previously started by `anonymizeProxy()`.
|
|
67
54
|
* If proxy was not found or was already closed, the function has no effect
|
|
68
55
|
* and its result if `false`. Otherwise the result is `true`.
|
|
69
56
|
* @param closeConnections If true, pending proxy connections are forcibly closed.
|
|
70
57
|
*/
|
|
71
|
-
const closeAnonymizedProxy = async (anonymizedProxyUrl, closeConnections
|
|
58
|
+
export const closeAnonymizedProxy = async (anonymizedProxyUrl, closeConnections) => {
|
|
72
59
|
if (typeof anonymizedProxyUrl !== 'string') {
|
|
73
60
|
throw new Error('The "anonymizedProxyUrl" parameter must be a string');
|
|
74
61
|
}
|
|
75
62
|
const server = anonymizedProxyUrlToServer[anonymizedProxyUrl];
|
|
76
63
|
if (!server) {
|
|
77
|
-
return
|
|
64
|
+
return false;
|
|
78
65
|
}
|
|
79
66
|
delete anonymizedProxyUrlToServer[anonymizedProxyUrl];
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
});
|
|
83
|
-
return (0, nodeify_1.nodeify)(promise, callback);
|
|
67
|
+
await server.close(closeConnections);
|
|
68
|
+
return true;
|
|
84
69
|
};
|
|
85
|
-
exports.closeAnonymizedProxy = closeAnonymizedProxy;
|
|
86
70
|
/**
|
|
87
71
|
* Add a callback on 'tunnelConnectResponded' Event in order to get headers from CONNECT tunnel to proxy
|
|
88
72
|
* Useful for some proxies that are using headers to send information like ProxyMesh
|
|
89
73
|
* @returns `true` if the callback is successfully configured, otherwise `false` (e.g. when an
|
|
90
74
|
* invalid proxy URL is given).
|
|
91
75
|
*/
|
|
92
|
-
const listenConnectAnonymizedProxy = (anonymizedProxyUrl, tunnelConnectRespondedCallback) => {
|
|
76
|
+
export const listenConnectAnonymizedProxy = (anonymizedProxyUrl, tunnelConnectRespondedCallback) => {
|
|
93
77
|
const server = anonymizedProxyUrlToServer[anonymizedProxyUrl];
|
|
94
78
|
if (!server) {
|
|
95
79
|
return false;
|
|
@@ -99,5 +83,4 @@ const listenConnectAnonymizedProxy = (anonymizedProxyUrl, tunnelConnectResponded
|
|
|
99
83
|
});
|
|
100
84
|
return true;
|
|
101
85
|
};
|
|
102
|
-
exports.listenConnectAnonymizedProxy = listenConnectAnonymizedProxy;
|
|
103
86
|
//# sourceMappingURL=anonymize_proxy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anonymize_proxy.js","sourceRoot":"","sources":["../src/anonymize_proxy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"anonymize_proxy.js","sourceRoot":"","sources":["../src/anonymize_proxy.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEtD,qFAAqF;AACrF,MAAM,0BAA0B,GAA2B,EAAE,CAAC;AAQ9D;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAC/B,OAAuC,EACxB,EAAE;IACjB,IAAI,QAAgB,CAAC;IACrB,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,IAAI,sBAAsB,GAAG,KAAK,CAAC;IAEnC,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC9B,QAAQ,GAAG,OAAO,CAAC;IACvB,CAAC;SAAM,CAAC;QACJ,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;QACvB,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QAEpB,IAAI,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,KAAK,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CACX,wEAAwE,CAC3E,CAAC;QACN,CAAC;QAED,IAAI,OAAO,CAAC,sBAAsB,KAAK,SAAS,EAAE,CAAC;YAC/C,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,CAAC;QAC5D,CAAC;IACL,CAAC;IAED,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;IACzC,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AC;IAED,MAAM,MAAM,GAAG,0BAA0B,CAAC,kBAAkB,CAAC,CAAC;IAC9D,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,OAAO,0BAA0B,CAAC,kBAAkB,CAAC,CAAC;IAEtD,MAAM,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACrC,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAYF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CACxC,kBAA0B,EAC1B,8BAAwC,EACjC,EAAE;IACT,MAAM,MAAM,GAAG,0BAA0B,CAAC,kBAAkB,CAAC,CAAC;IAC9D,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,MAAM,CAAC,EAAE,CAAC,wBAAwB,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE;QAC/D,8BAA8B,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC"}
|
package/dist/chain.d.ts
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
/// <reference types="node" />
|
|
4
|
-
/// <reference types="node" />
|
|
5
|
-
/// <reference types="node" />
|
|
6
|
-
/// <reference types="node" />
|
|
7
|
-
/// <reference types="node" />
|
|
8
1
|
import type { Buffer } from 'node:buffer';
|
|
9
2
|
import type dns from 'node:dns';
|
|
10
3
|
import type { EventEmitter } from 'node:events';
|
|
11
4
|
import http from 'node:http';
|
|
12
5
|
import https from 'node:https';
|
|
13
6
|
import type { URL } from 'node:url';
|
|
14
|
-
import type { Socket } from './socket';
|
|
7
|
+
import type { Socket } from './socket.js';
|
|
15
8
|
export interface HandlerOpts {
|
|
16
9
|
upstreamProxyUrlParsed: URL;
|
|
17
10
|
ignoreUpstreamProxyCertificate: boolean;
|
package/dist/chain.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../src/chain.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../src/chain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAEpC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAe1C,MAAM,WAAW,WAAW;IACxB,sBAAsB,EAAE,GAAG,CAAC;IAC5B,8BAA8B,EAAE,OAAO,CAAC;IACxC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,GAAG,CAAC,QAAQ,CAAC,CAAC;IACjC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC;IACvB,UAAU,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC;CAC5B;AAED,UAAU,SAAS;IACf,OAAO,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,WAAW,CAAC;IACzB,MAAM,EAAE,YAAY,GAAG;QAAE,GAAG,EAAE,CAAC,YAAY,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;KAAE,CAAC;IAC7E,OAAO,EAAE,OAAO,CAAC;CACpB;AAED;;;;GAIG;AACH,eAAO,MAAM,KAAK,GACd,gEAOG,SAAS,KACb,IAgKF,CAAC"}
|
package/dist/chain.js
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const node_https_1 = tslib_1.__importDefault(require("node:https"));
|
|
7
|
-
const statuses_1 = require("./statuses");
|
|
8
|
-
const count_target_bytes_1 = require("./utils/count_target_bytes");
|
|
9
|
-
const get_basic_1 = require("./utils/get_basic");
|
|
1
|
+
import http from 'node:http';
|
|
2
|
+
import https from 'node:https';
|
|
3
|
+
import { badGatewayStatusCodes, createCustomStatusHttpResponse, errorCodeToStatusCode } from './statuses.js';
|
|
4
|
+
import { countTargetBytes } from './utils/count_target_bytes.js';
|
|
5
|
+
import { getBasicAuthorizationHeader } from './utils/get_basic.js';
|
|
10
6
|
/**
|
|
11
7
|
* Passes the traffic to upstream HTTP proxy server.
|
|
12
8
|
* Client -> Apify -> Upstream -> Web
|
|
13
9
|
* Client <- Apify <- Upstream <- Web
|
|
14
10
|
*/
|
|
15
|
-
const chain = ({ request, sourceSocket, head, handlerOpts, server, isPlain, }) => {
|
|
11
|
+
export const chain = ({ request, sourceSocket, head, handlerOpts, server, isPlain, }) => {
|
|
16
12
|
if (head && head.length > 0) {
|
|
17
13
|
// HTTP/1.1 has no defined semantics when sending payload along with CONNECT and servers can reject the request.
|
|
18
14
|
// HTTP/2 only says that subsequent DATA frames must be transferred after HEADERS has been sent.
|
|
@@ -36,15 +32,15 @@ const chain = ({ request, sourceSocket, head, handlerOpts, server, isPlain, }) =
|
|
|
36
32
|
lookup: handlerOpts.dnsLookup,
|
|
37
33
|
};
|
|
38
34
|
if (proxy.username || proxy.password) {
|
|
39
|
-
options.headers['proxy-authorization'] =
|
|
35
|
+
options.headers['proxy-authorization'] = getBasicAuthorizationHeader(proxy);
|
|
40
36
|
}
|
|
41
37
|
const client = proxy.protocol === 'https:'
|
|
42
|
-
?
|
|
38
|
+
? https.request(proxy.origin, {
|
|
43
39
|
...options,
|
|
44
40
|
rejectUnauthorized: !handlerOpts.ignoreUpstreamProxyCertificate,
|
|
45
41
|
agent: handlerOpts.httpsAgent,
|
|
46
42
|
})
|
|
47
|
-
:
|
|
43
|
+
: http.request(proxy.origin, {
|
|
48
44
|
...options,
|
|
49
45
|
agent: handlerOpts.httpAgent,
|
|
50
46
|
});
|
|
@@ -53,7 +49,7 @@ const chain = ({ request, sourceSocket, head, handlerOpts, server, isPlain, }) =
|
|
|
53
49
|
// That's why we need to track the previous stats.
|
|
54
50
|
targetSocket.previousBytesRead = targetSocket.bytesRead;
|
|
55
51
|
targetSocket.previousBytesWritten = targetSocket.bytesWritten;
|
|
56
|
-
|
|
52
|
+
countTargetBytes(sourceSocket, targetSocket);
|
|
57
53
|
});
|
|
58
54
|
client.on('connect', (response, targetSocket, clientHead) => {
|
|
59
55
|
if (sourceSocket.readyState !== 'open') {
|
|
@@ -77,9 +73,9 @@ const chain = ({ request, sourceSocket, head, handlerOpts, server, isPlain, }) =
|
|
|
77
73
|
else {
|
|
78
74
|
const { statusCode } = response;
|
|
79
75
|
const status = statusCode === 401 || statusCode === 407
|
|
80
|
-
?
|
|
81
|
-
:
|
|
82
|
-
sourceSocket.end(
|
|
76
|
+
? badGatewayStatusCodes.AUTH_FAILED
|
|
77
|
+
: badGatewayStatusCodes.NON_200;
|
|
78
|
+
sourceSocket.end(createCustomStatusHttpResponse(status, `UPSTREAM${statusCode}`));
|
|
83
79
|
}
|
|
84
80
|
targetSocket.end();
|
|
85
81
|
server.emit('tunnelConnectFailed', {
|
|
@@ -123,7 +119,6 @@ const chain = ({ request, sourceSocket, head, handlerOpts, server, isPlain, }) =
|
|
|
123
119
|
});
|
|
124
120
|
});
|
|
125
121
|
client.on('error', (error) => {
|
|
126
|
-
var _a, _b;
|
|
127
122
|
server.log(proxyChainId, `Failed to connect to upstream proxy: ${error.stack}`);
|
|
128
123
|
// The end socket may get connected after the client to proxy one gets disconnected.
|
|
129
124
|
if (sourceSocket.readyState === 'open') {
|
|
@@ -131,8 +126,8 @@ const chain = ({ request, sourceSocket, head, handlerOpts, server, isPlain, }) =
|
|
|
131
126
|
sourceSocket.end();
|
|
132
127
|
}
|
|
133
128
|
else {
|
|
134
|
-
const statusCode =
|
|
135
|
-
const response =
|
|
129
|
+
const statusCode = errorCodeToStatusCode[error.code] ?? badGatewayStatusCodes.GENERIC_ERROR;
|
|
130
|
+
const response = createCustomStatusHttpResponse(statusCode, error.code ?? 'Upstream Closed Early');
|
|
136
131
|
sourceSocket.end(response);
|
|
137
132
|
}
|
|
138
133
|
}
|
|
@@ -146,5 +141,4 @@ const chain = ({ request, sourceSocket, head, handlerOpts, server, isPlain, }) =
|
|
|
146
141
|
});
|
|
147
142
|
client.end();
|
|
148
143
|
};
|
|
149
|
-
exports.chain = chain;
|
|
150
144
|
//# sourceMappingURL=chain.js.map
|
package/dist/chain.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain.js","sourceRoot":"","sources":["../src/chain.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chain.js","sourceRoot":"","sources":["../src/chain.ts"],"names":[],"mappings":"AAGA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,MAAM,YAAY,CAAC;AAI/B,OAAO,EAAE,qBAAqB,EAAE,8BAA8B,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE7G,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AA+BnE;;;;GAIG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CACjB,EACI,OAAO,EACP,YAAY,EACZ,IAAI,EACJ,WAAW,EACX,MAAM,EACN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;YAEtB,IAAI,YAAY,CAAC,QAAQ,EAAE,CAAC;gBACxB,YAAY,CAAC,GAAG,EAAE,CAAC;YACvB,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAA4B,EAAE,EAAE;QAChD,MAAM,CAAC,GAAG,CAAC,YAAY,EAAE,wCAAwC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;QAEhF,oFAAoF;QACpF,IAAI,YAAY,CAAC,UAAU,KAAK,MAAM,EAAE,CAAC;YACrC,IAAI,OAAO,EAAE,CAAC;gBACV,YAAY,CAAC,GAAG,EAAE,CAAC;YACvB,CAAC;iBAAM,CAAC;gBACJ,MAAM,UAAU,GAAG,qBAAqB,CAAC,KAAK,CAAC,IAAK,CAAC,IAAI,qBAAqB,CAAC,aAAa,CAAC;gBAC7F,MAAM,QAAQ,GAAG,8BAA8B,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,IAAI,uBAAuB,CAAC,CAAC;gBACnG,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC/B,CAAC;QACL,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;QAC1B,MAAM,CAAC,OAAO,EAAE,CAAC;IACrB,CAAC,CAAC,CAAC;IAEH,+CAA+C;IAC/C,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;QAC1B,MAAM,CAAC,OAAO,EAAE,CAAC;IACrB,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,GAAG,EAAE,CAAC;AACjB,CAAC,CAAC"}
|
package/dist/chain_socks.d.ts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
/// <reference types="node" />
|
|
4
|
-
/// <reference types="node" />
|
|
5
|
-
/// <reference types="node" />
|
|
6
1
|
import type { Buffer } from 'node:buffer';
|
|
7
2
|
import type { EventEmitter } from 'node:events';
|
|
8
3
|
import type http from 'node:http';
|
|
9
4
|
import { URL } from 'node:url';
|
|
10
|
-
import type { Socket } from './socket';
|
|
5
|
+
import type { Socket } from './socket.js';
|
|
11
6
|
export interface HandlerOpts {
|
|
12
7
|
upstreamProxyUrlParsed: URL;
|
|
13
8
|
customTag?: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain_socks.d.ts","sourceRoot":"","sources":["../src/chain_socks.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chain_socks.d.ts","sourceRoot":"","sources":["../src/chain_socks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAI/B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAI1C,MAAM,WAAW,WAAW;IACxB,sBAAsB,EAAE,GAAG,CAAC;IAC5B,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,UAAU,cAAc;IACpB,OAAO,EAAE,IAAI,CAAC,eAAe,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,YAAY,GAAG;QAAE,GAAG,EAAE,CAAC,YAAY,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;KAAE,CAAC;IAC7E,WAAW,EAAE,WAAW,CAAC;CAC5B;AAYD;;;;;;;;;GASG;AACH,eAAO,MAAM,UAAU,GAAU,uDAM9B,cAAc,KAAG,OAAO,CAAC,IAAI,CAoF/B,CAAC"}
|