Repository navigation
Conversation
Merge upstream master 6a641f3, including the architecture module-map and schedule-independent ranxianglei#2929 probe fixes. Preserve the existing PR head and exact contribution patch. Validation of this refreshed head runs in upstream CI; no local test rerun is claimed.
|
Review 结论:tunnel 侧修法正确(枚举 127/8 列表 → 连带变化:这个 PR 删掉了 修法: 已验证:新测试在未修代码上红、修后绿;admin-probe + tunnel-self-addresses + tunnel-guard 共 29/29 通过;typecheck 通过。 我对该分支没有 push 权限,请应用以下补丁(或给我写权限): From 9f594c159dfb824d2430c91fbca951bcb689c1a1 Mon Sep 17 00:00:00 2001
From: ranxianglei <ranxianglei@users.noreply.github.com>
Date: Wed, 18 Nov 2026 09:20:36 +0800
Subject: [PATCH] fix: keep unconfigured loopback aliases self-served in
selfAddressedLocalPath
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The tunnel-side fix stops enumerating 127.0.0.x in localMachineIps()
(classifyIp covers the range now), but selfAddressedLocalPath still
relies on the interface set — an absolute-form self request via an
unconfigured alias such as 127.0.0.5:selfport would fall through to
tunnel classification and 403 instead of being served locally.
(cherry-pick pending: proposed fix for PR #7022)
---
src/server.ts | 7 ++++++-
tests/admin-probe.test.ts | 2 ++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/server.ts b/src/server.ts
index 725588068..5984c6c28 100644
--- a/src/server.ts
+++ b/src/server.ts
@@ -233,7 +233,12 @@ export function selfAddressedLocalPath(reqUrl: string, localPort: number | undef
const port = u.port !== "" ? Number(u.port) : u.protocol === "https:" ? 443 : 80;
if (port !== localPort) return undefined;
const host = u.hostname.replace(/^\[|\]$/g, "").toLowerCase();
- const mine = host === "0.0.0.0" || host === "::" || host === "localhost" || localMachineIps().has(normalizeIpLiteral(host));
+ // #7022 review: classifyIp covers the whole loopback range, not just
+ // configured interfaces — the tunnel-side fix stopped enumerating
+ // 127.0.0.x in localMachineIps(), so an unconfigured alias like
+ // 127.0.0.5:selfport must still be recognized as self here (else it
+ // would fall through to tunnel classification and 403, #562 self-layer).
+ const mine = host === "0.0.0.0" || host === "::" || host === "localhost" || classifyIp(host) === "loopback" || localMachineIps().has(normalizeIpLiteral(host));
if (!mine) return undefined;
return u.pathname + u.search;
} catch {
diff --git a/tests/admin-probe.test.ts b/tests/admin-probe.test.ts
index da931f9fe..b39838084 100644
--- a/tests/admin-probe.test.ts
+++ b/tests/admin-probe.test.ts
@@ -41,6 +41,8 @@ test("selfAddressedLocalPath: self-addressed absolute-form requests only", () =>
assert.equal(selfAddressedLocalPath(`http://[::ffff:127.0.0.1]:${P}/__bili/health`, P), "/__bili/health", "hex-mapped loopback folds to 127.0.0.1");
assert.equal(selfAddressedLocalPath(`http://0.0.0.0:${P}/__bili/health`, P), "/__bili/health");
assert.equal(selfAddressedLocalPath(`http://[::]:${P}/__acp/x`, P), "/__acp/x", "v6 unspecified in brackets");
+ assert.equal(selfAddressedLocalPath(`http://127.0.0.5:${P}/__bili/health`, P), "/__bili/health", "unconfigured loopback alias is still self (#7022 review)");
+ assert.equal(selfAddressedLocalPath(`http://127.42.19.8:${P}/__bili/health`, P), "/__bili/health", "deep 127/8 alias is still self (#7022 review)");
// #3245: ANY path qualifies — model-style paths and the /bili/ zero-config
// entry are served locally exactly as a direct connection would send them.
assert.equal(selfAddressedLocalPath(`http://127.0.0.1:${P}/v1/chat/completions`, P), "/v1/chat/completions");
--
2.43.0
|
(ai: vllm-qwen/qwen3.8-27b) 已按你给的补丁在 PR 分支本地逐字节应用并验证通过,但推不上去——卡在写权限,和你撞的是同一道墙。 验证(本地已做)
推送受阻 八问
待你拍板(推送路径)
选 A 的话,加完 collaborator 告诉我一声,我立刻把 |
…ocalPath The tunnel-side fix stops enumerating 127.0.0.x in localMachineIps() (classifyIp covers the range now), but selfAddressedLocalPath still relies on the interface set — an absolute-form self request via an unconfigured alias such as 127.0.0.5:selfport would fall through to tunnel classification and 403 instead of being served locally. (cherry-pick pending: proposed fix for PR ranxianglei#7022) (cherry picked from commit 9f594c159dfb824d2430c91fbca951bcb689c1a1)
Problem
Tunnel admission's self check represents loopback by a finite interface set, adding only the first 256 IPv4 loopback addresses. Other
127/8addresses can pass the serving-port check. DNS-returned IPv4-mapped addresses also use a different representation from ordinary interface addresses and miss the same check.Change
Use the existing loopback range classifier for same-port self detection. Normalize resolver and interface addresses before testing membership. Remove the incomplete loopback enumeration. The self check remains ahead of allowlist handling; other ports and other machines preserve their existing behavior.
Verification
301e1a5459a77d5578206927c8062a58381af642(0.1.215), confirmed current before implementation.os.networkInterfaces()(uv_interface_addresses), so local HTTP checks supply a known interface inventory; production behavior was not changed to accommodate the restriction.npm run typecheck,npm run build, andgit diff --check: passed.This restores the documented self-destination policy. It is distinct from #6354's inbound-Host marker exemption. No wire format, kernel, config-schema, or dependency changes.
Fixes #7021