fix(socks): downgrade socks-proxy-agent to fix two failing tests on main
This commit is contained in:
parent
d3fbf1aaeb
commit
8703779c1c
|
|
@ -6,6 +6,7 @@ This project incorporates components from the projects listed below. The origina
|
|||
|
||||
- @types/node@17.0.24 (https://github.com/DefinitelyTyped/DefinitelyTyped)
|
||||
- @types/yauzl@2.10.0 (https://github.com/DefinitelyTyped/DefinitelyTyped)
|
||||
- agent-base@6.0.2 (https://github.com/TooTallNate/node-agent-base)
|
||||
- agent-base@7.1.1 (https://github.com/TooTallNate/proxy-agents)
|
||||
- balanced-match@1.0.2 (https://github.com/juliangruber/balanced-match)
|
||||
- brace-expansion@1.1.11 (https://github.com/juliangruber/brace-expansion)
|
||||
|
|
@ -42,7 +43,7 @@ This project incorporates components from the projects listed below. The origina
|
|||
- retry@0.12.0 (https://github.com/tim-kos/node-retry)
|
||||
- signal-exit@3.0.7 (https://github.com/tapjs/signal-exit)
|
||||
- smart-buffer@4.2.0 (https://github.com/JoshGlazebrook/smart-buffer)
|
||||
- socks-proxy-agent@8.0.4 (https://github.com/TooTallNate/proxy-agents)
|
||||
- socks-proxy-agent@6.1.1 (https://github.com/TooTallNate/node-socks-proxy-agent)
|
||||
- socks@2.8.3 (https://github.com/JoshGlazebrook/socks)
|
||||
- sprintf-js@1.1.3 (https://github.com/alexei/sprintf.js)
|
||||
- stack-utils@2.0.5 (https://github.com/tapjs/stack-utils)
|
||||
|
|
@ -103,6 +104,156 @@ MIT License
|
|||
=========================================
|
||||
END OF @types/yauzl@2.10.0 AND INFORMATION
|
||||
|
||||
%% agent-base@6.0.2 NOTICES AND INFORMATION BEGIN HERE
|
||||
=========================================
|
||||
agent-base
|
||||
==========
|
||||
### Turn a function into an [`http.Agent`][http.Agent] instance
|
||||
[](https://github.com/TooTallNate/node-agent-base/actions?workflow=Node+CI)
|
||||
|
||||
This module provides an `http.Agent` generator. That is, you pass it an async
|
||||
callback function, and it returns a new `http.Agent` instance that will invoke the
|
||||
given callback function when sending outbound HTTP requests.
|
||||
|
||||
#### Some subclasses:
|
||||
|
||||
Here's some more interesting uses of `agent-base`.
|
||||
Send a pull request to list yours!
|
||||
|
||||
* [`http-proxy-agent`][http-proxy-agent]: An HTTP(s) proxy `http.Agent` implementation for HTTP endpoints
|
||||
* [`https-proxy-agent`][https-proxy-agent]: An HTTP(s) proxy `http.Agent` implementation for HTTPS endpoints
|
||||
* [`pac-proxy-agent`][pac-proxy-agent]: A PAC file proxy `http.Agent` implementation for HTTP and HTTPS
|
||||
* [`socks-proxy-agent`][socks-proxy-agent]: A SOCKS proxy `http.Agent` implementation for HTTP and HTTPS
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
Install with `npm`:
|
||||
|
||||
``` bash
|
||||
$ npm install agent-base
|
||||
```
|
||||
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
Here's a minimal example that creates a new `net.Socket` connection to the server
|
||||
for every HTTP request (i.e. the equivalent of `agent: false` option):
|
||||
|
||||
```js
|
||||
var net = require('net');
|
||||
var tls = require('tls');
|
||||
var url = require('url');
|
||||
var http = require('http');
|
||||
var agent = require('agent-base');
|
||||
|
||||
var endpoint = 'http://nodejs.org/api/';
|
||||
var parsed = url.parse(endpoint);
|
||||
|
||||
// This is the important part!
|
||||
parsed.agent = agent(function (req, opts) {
|
||||
var socket;
|
||||
// `secureEndpoint` is true when using the https module
|
||||
if (opts.secureEndpoint) {
|
||||
socket = tls.connect(opts);
|
||||
} else {
|
||||
socket = net.connect(opts);
|
||||
}
|
||||
return socket;
|
||||
});
|
||||
|
||||
// Everything else works just like normal...
|
||||
http.get(parsed, function (res) {
|
||||
console.log('"response" event!', res.headers);
|
||||
res.pipe(process.stdout);
|
||||
});
|
||||
```
|
||||
|
||||
Returning a Promise or using an `async` function is also supported:
|
||||
|
||||
```js
|
||||
agent(async function (req, opts) {
|
||||
await sleep(1000);
|
||||
// etc…
|
||||
});
|
||||
```
|
||||
|
||||
Return another `http.Agent` instance to "pass through" the responsibility
|
||||
for that HTTP request to that agent:
|
||||
|
||||
```js
|
||||
agent(function (req, opts) {
|
||||
return opts.secureEndpoint ? https.globalAgent : http.globalAgent;
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
API
|
||||
---
|
||||
|
||||
## Agent(Function callback[, Object options]) → [http.Agent][]
|
||||
|
||||
Creates a base `http.Agent` that will execute the callback function `callback`
|
||||
for every HTTP request that it is used as the `agent` for. The callback function
|
||||
is responsible for creating a `stream.Duplex` instance of some kind that will be
|
||||
used as the underlying socket in the HTTP request.
|
||||
|
||||
The `options` object accepts the following properties:
|
||||
|
||||
* `timeout` - Number - Timeout for the `callback()` function in milliseconds. Defaults to Infinity (optional).
|
||||
|
||||
The callback function should have the following signature:
|
||||
|
||||
### callback(http.ClientRequest req, Object options, Function cb) → undefined
|
||||
|
||||
The ClientRequest `req` can be accessed to read request headers and
|
||||
and the path, etc. The `options` object contains the options passed
|
||||
to the `http.request()`/`https.request()` function call, and is formatted
|
||||
to be directly passed to `net.connect()`/`tls.connect()`, or however
|
||||
else you want a Socket to be created. Pass the created socket to
|
||||
the callback function `cb` once created, and the HTTP request will
|
||||
continue to proceed.
|
||||
|
||||
If the `https` module is used to invoke the HTTP request, then the
|
||||
`secureEndpoint` property on `options` _will be set to `true`_.
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
[http-proxy-agent]: https://github.com/TooTallNate/node-http-proxy-agent
|
||||
[https-proxy-agent]: https://github.com/TooTallNate/node-https-proxy-agent
|
||||
[pac-proxy-agent]: https://github.com/TooTallNate/node-pac-proxy-agent
|
||||
[socks-proxy-agent]: https://github.com/TooTallNate/node-socks-proxy-agent
|
||||
[http.Agent]: https://nodejs.org/api/http.html#http_class_http_agent
|
||||
=========================================
|
||||
END OF agent-base@6.0.2 AND INFORMATION
|
||||
|
||||
%% agent-base@7.1.1 NOTICES AND INFORMATION BEGIN HERE
|
||||
=========================================
|
||||
(The MIT License)
|
||||
|
|
@ -969,11 +1120,141 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
=========================================
|
||||
END OF smart-buffer@4.2.0 AND INFORMATION
|
||||
|
||||
%% socks-proxy-agent@8.0.4 NOTICES AND INFORMATION BEGIN HERE
|
||||
%% socks-proxy-agent@6.1.1 NOTICES AND INFORMATION BEGIN HERE
|
||||
=========================================
|
||||
socks-proxy-agent
|
||||
================
|
||||
### A SOCKS proxy `http.Agent` implementation for HTTP and HTTPS
|
||||
[](https://github.com/TooTallNate/node-socks-proxy-agent/actions?workflow=Node+CI)
|
||||
|
||||
This module provides an `http.Agent` implementation that connects to a
|
||||
specified SOCKS proxy server, and can be used with the built-in `http`
|
||||
and `https` modules.
|
||||
|
||||
It can also be used in conjunction with the `ws` module to establish a WebSocket
|
||||
connection over a SOCKS proxy. See the "Examples" section below.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
Install with `npm`:
|
||||
|
||||
``` bash
|
||||
$ npm install socks-proxy-agent
|
||||
```
|
||||
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
#### TypeScript example
|
||||
|
||||
```ts
|
||||
import https from 'https';
|
||||
import { SocksProxyAgent } from 'socks-proxy-agent';
|
||||
|
||||
const info = {
|
||||
host: 'br41.nordvpn.com',
|
||||
userId: 'your-name@gmail.com',
|
||||
password: 'abcdef12345124'
|
||||
};
|
||||
const agent = new SocksProxyAgent(info);
|
||||
|
||||
https.get('https://jsonip.org', { agent }, (res) => {
|
||||
console.log(res.headers);
|
||||
res.pipe(process.stdout);
|
||||
});
|
||||
```
|
||||
|
||||
#### `http` module example
|
||||
|
||||
```js
|
||||
var url = require('url');
|
||||
var http = require('http');
|
||||
var SocksProxyAgent = require('socks-proxy-agent');
|
||||
|
||||
// SOCKS proxy to connect to
|
||||
var proxy = process.env.socks_proxy || 'socks://127.0.0.1:1080';
|
||||
console.log('using proxy server %j', proxy);
|
||||
|
||||
// HTTP endpoint for the proxy to connect to
|
||||
var endpoint = process.argv[2] || 'http://nodejs.org/api/';
|
||||
console.log('attempting to GET %j', endpoint);
|
||||
var opts = url.parse(endpoint);
|
||||
|
||||
// create an instance of the `SocksProxyAgent` class with the proxy server information
|
||||
var agent = new SocksProxyAgent(proxy);
|
||||
opts.agent = agent;
|
||||
|
||||
http.get(opts, function (res) {
|
||||
console.log('"response" event!', res.headers);
|
||||
res.pipe(process.stdout);
|
||||
});
|
||||
```
|
||||
|
||||
#### `https` module example
|
||||
|
||||
```js
|
||||
var url = require('url');
|
||||
var https = require('https');
|
||||
var SocksProxyAgent = require('socks-proxy-agent');
|
||||
|
||||
// SOCKS proxy to connect to
|
||||
var proxy = process.env.socks_proxy || 'socks://127.0.0.1:1080';
|
||||
console.log('using proxy server %j', proxy);
|
||||
|
||||
// HTTP endpoint for the proxy to connect to
|
||||
var endpoint = process.argv[2] || 'https://encrypted.google.com/';
|
||||
console.log('attempting to GET %j', endpoint);
|
||||
var opts = url.parse(endpoint);
|
||||
|
||||
// create an instance of the `SocksProxyAgent` class with the proxy server information
|
||||
var agent = new SocksProxyAgent(proxy);
|
||||
opts.agent = agent;
|
||||
|
||||
https.get(opts, function (res) {
|
||||
console.log('"response" event!', res.headers);
|
||||
res.pipe(process.stdout);
|
||||
});
|
||||
```
|
||||
|
||||
#### `ws` WebSocket connection example
|
||||
|
||||
``` js
|
||||
var WebSocket = require('ws');
|
||||
var SocksProxyAgent = require('socks-proxy-agent');
|
||||
|
||||
// SOCKS proxy to connect to
|
||||
var proxy = process.env.socks_proxy || 'socks://127.0.0.1:1080';
|
||||
console.log('using proxy server %j', proxy);
|
||||
|
||||
// WebSocket endpoint for the proxy to connect to
|
||||
var endpoint = process.argv[2] || 'ws://echo.websocket.org';
|
||||
console.log('attempting to connect to WebSocket %j', endpoint);
|
||||
|
||||
// create an instance of the `SocksProxyAgent` class with the proxy server information
|
||||
var agent = new SocksProxyAgent(proxy);
|
||||
|
||||
// initiate the WebSocket connection
|
||||
var socket = new WebSocket(endpoint, { agent: agent });
|
||||
|
||||
socket.on('open', function () {
|
||||
console.log('"open" event!');
|
||||
socket.send('hello world');
|
||||
});
|
||||
|
||||
socket.on('message', function (data, flags) {
|
||||
console.log('"message" event! %j %j', data, flags);
|
||||
socket.close();
|
||||
});
|
||||
```
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net>
|
||||
Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
|
@ -994,7 +1275,7 @@ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
=========================================
|
||||
END OF socks-proxy-agent@8.0.4 AND INFORMATION
|
||||
END OF socks-proxy-agent@6.1.1 AND INFORMATION
|
||||
|
||||
%% socks@2.8.3 NOTICES AND INFORMATION BEGIN HERE
|
||||
=========================================
|
||||
|
|
@ -1175,6 +1456,6 @@ END OF yazl@2.5.1 AND INFORMATION
|
|||
|
||||
SUMMARY BEGIN HERE
|
||||
=========================================
|
||||
Total Packages: 46
|
||||
Total Packages: 47
|
||||
=========================================
|
||||
END OF SUMMARY
|
||||
|
|
@ -23,7 +23,7 @@
|
|||
"proxy-from-env": "1.1.0",
|
||||
"retry": "0.12.0",
|
||||
"signal-exit": "3.0.7",
|
||||
"socks-proxy-agent": "8.0.4",
|
||||
"socks-proxy-agent": "6.1.1",
|
||||
"stack-utils": "2.0.5",
|
||||
"ws": "8.17.1"
|
||||
},
|
||||
|
|
@ -384,17 +384,29 @@
|
|||
}
|
||||
},
|
||||
"node_modules/socks-proxy-agent": {
|
||||
"version": "8.0.4",
|
||||
"resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-8.0.4.tgz",
|
||||
"integrity": "sha512-GNAq/eg8Udq2x0eNiFkr9gRg5bA7PXEWagQdeRX4cPSG+X/8V38v637gim9bjFptMk1QWsCTr0ttrJEiXbNnRw==",
|
||||
"version": "6.1.1",
|
||||
"resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-6.1.1.tgz",
|
||||
"integrity": "sha512-t8J0kG3csjA4g6FTbsMOWws+7R7vuRC8aQ/wy3/1OWmsgwA68zs/+cExQ0koSitUDXqhufF/YJr9wtNMZHw5Ew==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"agent-base": "^7.1.1",
|
||||
"debug": "^4.3.4",
|
||||
"socks": "^2.8.3"
|
||||
"agent-base": "^6.0.2",
|
||||
"debug": "^4.3.1",
|
||||
"socks": "^2.6.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
"node": ">= 10"
|
||||
}
|
||||
},
|
||||
"node_modules/socks-proxy-agent/node_modules/agent-base": {
|
||||
"version": "6.0.2",
|
||||
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
|
||||
"integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"debug": "4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/sprintf-js": {
|
||||
|
|
@ -699,13 +711,23 @@
|
|||
}
|
||||
},
|
||||
"socks-proxy-agent": {
|
||||
"version": "8.0.4",
|
||||
"resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-8.0.4.tgz",
|
||||
"integrity": "sha512-GNAq/eg8Udq2x0eNiFkr9gRg5bA7PXEWagQdeRX4cPSG+X/8V38v637gim9bjFptMk1QWsCTr0ttrJEiXbNnRw==",
|
||||
"version": "6.1.1",
|
||||
"resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-6.1.1.tgz",
|
||||
"integrity": "sha512-t8J0kG3csjA4g6FTbsMOWws+7R7vuRC8aQ/wy3/1OWmsgwA68zs/+cExQ0koSitUDXqhufF/YJr9wtNMZHw5Ew==",
|
||||
"requires": {
|
||||
"agent-base": "^7.1.1",
|
||||
"debug": "^4.3.4",
|
||||
"socks": "^2.8.3"
|
||||
"agent-base": "^6.0.2",
|
||||
"debug": "^4.3.1",
|
||||
"socks": "^2.6.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"agent-base": {
|
||||
"version": "6.0.2",
|
||||
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
|
||||
"integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==",
|
||||
"requires": {
|
||||
"debug": "4"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"sprintf-js": {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
"proxy-from-env": "1.1.0",
|
||||
"retry": "0.12.0",
|
||||
"signal-exit": "3.0.7",
|
||||
"socks-proxy-agent": "8.0.4",
|
||||
"socks-proxy-agent": "6.1.1",
|
||||
"stack-utils": "2.0.5",
|
||||
"ws": "8.17.1"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -691,7 +691,7 @@ export class GlobalAPIRequestContext extends APIRequestContext {
|
|||
export function createProxyAgent(proxy: types.ProxySettings) {
|
||||
const proxyURL = new URL(proxy.server);
|
||||
if (proxyURL.protocol?.startsWith('socks'))
|
||||
return new SocksProxyAgent(proxyURL);
|
||||
return new SocksProxyAgent({ host: proxyURL.hostname, port: proxyURL.port });
|
||||
|
||||
if (proxy.username)
|
||||
proxyURL.username = proxy.username;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import { debugLogger } from '../utils/debugLogger';
|
|||
import { createProxyAgent } from './fetch';
|
||||
import { EventEmitter } from 'events';
|
||||
import { verifyClientCertificates } from './browserContext';
|
||||
import { SocksProxyAgent } from '../utilsBundle';
|
||||
|
||||
let dummyServerTlsOptions: tls.TlsOptions | undefined = undefined;
|
||||
function loadDummyServerCertsIfNeeded() {
|
||||
|
|
@ -97,8 +98,8 @@ class SocksProxyConnection {
|
|||
}
|
||||
|
||||
async connect() {
|
||||
if (this.socksProxy.proxyAgentFromOptions)
|
||||
this.target = await this.socksProxy.proxyAgentFromOptions.connect(new EventEmitter() as any, { host: rewriteToLocalhostIfNeeded(this.host), port: this.port, secureEndpoint: false });
|
||||
if (this.socksProxy.proxyAgentFromOptions instanceof SocksProxyAgent)
|
||||
this.target = await this.socksProxy.proxyAgentFromOptions.callback(new EventEmitter() as any, { host: rewriteToLocalhostIfNeeded(this.host), port: this.port, secureEndpoint: false });
|
||||
else
|
||||
this.target = await createSocket(rewriteToLocalhostIfNeeded(this.host), this.port);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue