proxy: support setting proxy via --proxyServer, PROXY_SERVER env var or PROXY_HOST + PROXY_PORT env vars (#589)

fixes #587 

The proxy env vars PROXY_HOST and PROXY_PORT were being ignored, as they
were hardcoded to obsolete values in the Dockerfile.

Proxy settings can now be set, in order of precedence via:
- --proxyServer cli flag
- PROXY_SERVER env var
- PROXY_HOST and PROXY_PORT env vars, which set an HTTP proxy server
only (for backwards compatibility with 0.12.x)

The --proxyServer / PROXY_SERVER settings are passed to the browser via
the --proxy-server flag.
AsyncFetcher / direct fetch also supports HTTP and SOCKS5 proxying.
Supported proxies are: HTTP no auth, SOCKS5 no auth, SOCKS5 with auth
(supported in Brave, but not Chrome!)

---------
Co-authored-by: Vinzenz Sinapius <Vinzenz.Sinapius@gmail.com>
Co-authored-by: Tessa Walsh <tessa@bitarchivist.net>
This commit is contained in:
Ilya Kreymer 2024-06-10 13:11:00 -07:00 committed by GitHub
parent b83d1c58da
commit e2b4cc1844
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 262 additions and 17 deletions

View file

@ -99,9 +99,10 @@ function cliOpts(): { [key: string]: Options } {
default: getDefaultWindowSize(),
},
proxy: {
type: "boolean",
default: false,
proxyServer: {
describe:
"if set, will use specified proxy server. Takes precedence over any env var proxy settings",
type: "string",
},
cookieDays: {
@ -179,7 +180,7 @@ async function main() {
headless: params.headless,
signals: false,
chromeOptions: {
proxy: false,
proxy: params.proxyServer,
extraArgs: [
"--window-position=0,0",
`--window-size=${params.windowSize}`,