From 322d92a0c473ab3151a8aeecdd5d117a8d41201b Mon Sep 17 00:00:00 2001 From: Eridanus Sora Date: Sat, 24 Feb 2024 00:09:51 +0800 Subject: [PATCH] add --no-proxy to disable reading proxy settings from system context --- readme.md | 7 ++++--- src/index.ts | 18 +++++++++++++----- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/readme.md b/readme.md index bc9f751..e043664 100644 --- a/readme.md +++ b/readme.md @@ -50,6 +50,7 @@ Help: Format name. ts or mkv. --proxy Use the specified HTTP/HTTPS/SOCKS5 proxy Set proxy in [protocol://:] format. eg. --proxy "http://127.0.0.1:1080". + --no-proxy Disable reading proxy configuration from system environment variables or system settings. --slice Download specified part of the stream Set time range in [- format]. eg. --slice "45:00-53:00" --no-merge Do not merge m3u8 chunks. @@ -64,7 +65,6 @@ Options: Options Description --verbose, debug Debug output - ``` ## FAQ @@ -75,11 +75,12 @@ A: It's not necessary. Q: How to set proxy for Minyami? -A: You can use `--proxy` to set proxy server for Minyami. HTTP/SOCKS5 proxy are supported. Or you can use environment variables `HTTP_PROXY`/`HTTPS_PROXY`/`ALL_PROXY` to provide proxy configuration for Minyami. +A: You can use `--proxy` to set proxy server for Minyami. HTTP/SOCKS5 proxy are supported. Or you can use environment variables `HTTP_PROXY`/`HTTPS_PROXY`/`ALL_PROXY` to provide proxy configuration for Minyami. And Minyami will read proxy settings from environment variables and Windows system proxy settings. To disable any proxy setting from context, you can add `--disable-proxy` or set `env.NO_PROXY` to and non-empty values. + Q: How to set temporary file location? -A: You can use environment variables to set the directory of temporary files. See [Issue #80](https://github.com/Last-Order/Minyami/issues/80#issuecomment-869132412). +A: You can use `--temp-dir` to set the directory of temporary files. Q: How to set multiple HTTP headers? diff --git a/src/index.ts b/src/index.ts index 881339e..4f78edf 100644 --- a/src/index.ts +++ b/src/index.ts @@ -52,11 +52,13 @@ Erii.bind( }, async (ctx, options) => { const path = ctx.getArgument().toString(); - if (options.verbose) { - logger.enableDebugMode(); - } - if (process.platform === "win32") { - await ProxyAgent.readWindowsSystemProxy(); + if (!options.noProxy && !process.env.NO_PROXY) { + if (options.verbose) { + logger.enableDebugMode(); + } + if (process.platform === "win32") { + await ProxyAgent.readWindowsSystemProxy(); + } } ProxyAgent.readProxyConfigurationFromEnv(); const fileOptions = readConfigFile(); @@ -264,6 +266,12 @@ Erii.addOption({ }, }); +Erii.addOption({ + name: ["no-proxy"], + command: "download", + description: "Disable reading proxy configuration from system environment variables or system settings.", +}); + Erii.addOption({ name: ["slice"], command: "download",