mirror of
https://github.com/ranxianglei/billion-context.git
synced 2026-11-23 01:58:16 +08:00
- Unset upstreamProxyMode now resolves to "direct" (matches the web UI's 直连(默认) and ZCode's default) instead of falling through to env/system proxy auto-detection. Set mode "auto" to follow the system/env proxy; an explicit proxy (-F / BILI_UPSTREAM_PROXY / config) still wins regardless. - Add `-F <url>` (gost-style --forward) to set the upstream proxy for a run; works for launcher cmds (before the client name) and `start`. HTTP/HTTPS only for now (SOCKS5 is a follow-up). - Log the resolved upstream-proxy decision once per unique (host, proxy, source) — `[upstream-proxy] <host> via <proxy> (source=<source>)` — with non-public hosts masked (#255), so a silently-picked env proxy is visible. - Fix the misleading `bili pi --mitm-domain ...` help example (that form forwarded the flag to the client; the working form is `bili --mitm-domain ... pi`). Tests: default-direct (unset mode ignores HTTPS_PROXY), auto-mode opt-in still follows the env proxy, and parseArgs -F placement (before/after client, start cmd, composition).
36 lines
1.5 KiB
TypeScript
36 lines
1.5 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { parseArgs } from "../src/cli.ts";
|
|
|
|
// #346: the gost-style `-F <url>` (forward) flag sets bili's upstream proxy.
|
|
// bili flags must precede the client name; everything after the client name is
|
|
// forwarded to the client.
|
|
|
|
test("parseArgs: -F before the client sets BILI_UPSTREAM_PROXY (#346)", () => {
|
|
const r = parseArgs(["-F", "http://127.0.0.1:7897", "codex"]);
|
|
assert.equal(r.client, "codex");
|
|
assert.equal(r.overrides.BILI_UPSTREAM_PROXY, "http://127.0.0.1:7897");
|
|
assert.deepEqual(r.clientArgs, []);
|
|
});
|
|
|
|
test("parseArgs: -F after the client is forwarded to the client, not bili (#346)", () => {
|
|
const r = parseArgs(["codex", "-F", "http://127.0.0.1:7897"]);
|
|
assert.equal(r.client, "codex");
|
|
assert.equal(r.overrides.BILI_UPSTREAM_PROXY, undefined);
|
|
assert.deepEqual(r.clientArgs, ["-F", "http://127.0.0.1:7897"]);
|
|
});
|
|
|
|
test("parseArgs: -F works for the start command too (#346)", () => {
|
|
const r = parseArgs(["-F", "http://127.0.0.1:7897", "start"]);
|
|
assert.equal(r.command, "start");
|
|
assert.equal(r.overrides.BILI_UPSTREAM_PROXY, "http://127.0.0.1:7897");
|
|
});
|
|
|
|
test("parseArgs: -F composes with other bili flags before the client (#346)", () => {
|
|
const r = parseArgs(["--port", "9000", "-F", "http://127.0.0.1:7897", "pi"]);
|
|
assert.equal(r.client, "pi");
|
|
assert.equal(r.overrides.ACP_PORT, "9000");
|
|
assert.equal(r.overrides.BILI_UPSTREAM_PROXY, "http://127.0.0.1:7897");
|
|
assert.deepEqual(r.clientArgs, []);
|
|
});
|