diff --git a/script-meta-v2.json b/script-meta-v2.json index 07c0c63..42890db 100644 --- a/script-meta-v2.json +++ b/script-meta-v2.json @@ -367,11 +367,11 @@ }, "wget.ts": { "script_name": "wget.ts", - "script_length": 4888, - "script_sha256": "de6ac5033d0ba57493d445045a201196bc214264667720cd16d8b45cfd1aa193", + "script_length": 5270, + "script_sha256": "e66f9040be37f338a27d4d25c45aa119ee0198f2629fa168cd967ebb62c96be7", "script_full_url": "https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/single-scripts/wget.ts", "single_script_file": true, "publish_time": 1737272626139, - "update_time": 1775958189203 + "update_time": 1775958487427 } } \ No newline at end of file diff --git a/single-scripts/wget.ts b/single-scripts/wget.ts index 00a19a7..c283c12 100755 --- a/single-scripts/wget.ts +++ b/single-scripts/wget.ts @@ -15,6 +15,7 @@ import { log, printLastLine, } from "https://script.hatter.ink/@70/deno-commons-mod.ts"; +import {getEnv} from "../libraries/deno-commons-mod.ts"; function getOutputFilename(filename: string): string { const original = filename; @@ -50,14 +51,21 @@ function getOutputFilenameFromUrl(url: string): string { return getOutputFilename(getFilenameFromUrl(url)); } -function getEnvironmentProxy(): string | undefined { - return Deno.env.get("ALL_PROXY") || Deno.env.get("HTTPS_PROXY") || +function getEnvironmentProxy(autoProxy: boolean): string | undefined { + const proxy = Deno.env.get("ALL_PROXY") || Deno.env.get("HTTPS_PROXY") || Deno.env.get("HTTP_PROXY"); + if (proxy) { + return proxy; + } + if (autoProxy) { + return getEnv("AUTO_PROXY"); + } + return undefined; } const args = Deno.args; const flags = parseArgs(Deno.args, { - boolean: ["help", "no-proxy", "hatter-proxy"], + boolean: ["help", "no-proxy", "auto-proxy", "hatter-proxy"], string: ["proxy", "output"], }); @@ -68,7 +76,11 @@ if (args.length === 0) { if (flags.help) { console.log(`wget.ts - download file -wget.ts [--proxy socks5h://ip:port] [--no-proxy] [--hatter-proxy] [--output filename] `); +Environments: +- ALL_PROXY,HTTPS_PROXY,HTTP_PROXY ~ For proxy +- AUTO_PROXY ~ For auto proxy + +wget.ts [--proxy socks5h://ip:port] [--no-proxy] [--auto-proxy] [--hatter-proxy] [--output filename] `); Deno.exit(0); } @@ -109,8 +121,9 @@ const outputFileWritable = Deno.createSync(outputFilename).writable; let init = undefined; const noProxy = flags["no-proxy"]; +const autoProxy = flags["auto-proxy"]; const hatterProxy = flags["hatter-proxy"]; -const proxy = flags.proxy || getEnvironmentProxy(); +const proxy = flags.proxy || getEnvironmentProxy(autoProxy); if (proxy && !noProxy && !hatterProxy) { log.info(`Using proxy: ${proxy}`); init = { @@ -167,5 +180,5 @@ log.success( }`, ); -// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260412T094236+08:00.MEUCIB55YAAJvIXHI4GyG1V/ -// FtnHQSOh9GTJv4saSFZKoCvdAiEA/VKd6+MnnfWlw3aT8HrOLl/hT0j1cxtUfGjW84MoHS4= +// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260412T094803+08:00.MEUCIBdigqOZCNwVHEF/AEpP +// CSTp8ru7SCFX0MeB0N3PsGUhAiEA/gZ1cbK/FyK9w14+63YvxdTUwX273b+LgteJ95BjGag=