fix(sites): 站点开代理但没填代理地址时沿用容器 HTTPS_PROXY;内置公开 BT 站默认开代理

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
rootandClaude Opus 5.5 committed 2026-10-02 23:08:04 +08:00
1 parent 364b24bc33
commit b2cdf0e106
4 files changed
+17 -5

No files matched your search

+8 -3
View File
@@ -72,14 +72,19 @@ export function fetchVia(client: Deno.HttpClient): typeof globalThis.fetch {
globalThis.fetch(input, { ...init, client } as RequestInit)) as typeof globalThis.fetch;
}
/** 站点请求的出口:开代理且有代理地址 → proxy,否则 direct */
/** 站点请求的出口:开代理 → 设置里的站点代理地址,没填则用进程的 HTTPS_PROXY / HTTP_PROXY;都没有 → direct */
export interface SiteEgress {
mode: "direct" | "proxy";
proxyUrl: string | null;
}
export function siteEgress(proxy: boolean, proxyUrl: string | null | undefined): SiteEgress {
return proxy && proxyUrl ? { mode: "proxy", proxyUrl } : { mode: "direct", proxyUrl: null };
export function siteEgress(
proxy: boolean,
proxyUrl: string | null | undefined,
env: Record<string, string | undefined> = ENV_SNAPSHOT,
): SiteEgress {
const url = proxy ? proxyUrl || env.HTTPS_PROXY || env.https_proxy || env.HTTP_PROXY || env.http_proxy : null;
return url ? { mode: "proxy", proxyUrl: url } : { mode: "direct", proxyUrl: null };
}
/** 出口的比较键(不含代理口令):direct / proxy:<主机:端口> */
@@ -184,7 +184,8 @@ export function sourcesRoutes(app: ModuleApp, rt: () => SourcesRuntime) {
snapshot_enabled:
kind === "pt" ? (body.snapshotEnabled ?? false) : publicDef ? (body.snapshotEnabled ?? true) : false,
snapshot_interval_sec: body.snapshotIntervalSec ?? null,
proxy: body.proxy ?? false,
// 内置公开 BT 站(Nyaa 等)国内多数直连不通:默认走代理
proxy: body.proxy ?? !!publicDef,
// 不能搜索的站点不进默认搜索集合
search_default:
kind === "pt" ? (body.searchDefault ?? true) : publicDef ? (body.searchDefault ?? false) : false,