fix: honor bare ipv6 no_proxy entries · openclaw/openclaw@a23a668
steipete
·
2026-05-29
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -293,6 +293,12 @@ describe("matchesNoProxy", () => {
|
293 | 293 | env: { NO_PROXY: "[::1]:8080" } as NodeJS.ProcessEnv, |
294 | 294 | expected: true, |
295 | 295 | }, |
| 296 | +{ |
| 297 | +name: "matches bare IPv6 literal", |
| 298 | +url: "http://[::1]:8080/health", |
| 299 | +env: { NO_PROXY: "::1" } as NodeJS.ProcessEnv, |
| 300 | +expected: true, |
| 301 | +}, |
296 | 302 | { |
297 | 303 | name: "matches IPv4 CIDR entries", |
298 | 304 | url: "http://100.64.0.3:8990/v1/messages", |
@@ -387,6 +393,15 @@ describe("shouldUseEnvHttpProxyForUrl", () => {
|
387 | 393 | } as NodeJS.ProcessEnv, |
388 | 394 | expected: false, |
389 | 395 | }, |
| 396 | +{ |
| 397 | +name: "keeps strict mode for bare IPv6 NO_PROXY matches", |
| 398 | +url: "http://[::1]:11434/v1", |
| 399 | +env: { |
| 400 | +HTTP_PROXY: "http://proxy.test:8080", |
| 401 | +NO_PROXY: "::1", |
| 402 | +} as NodeJS.ProcessEnv, |
| 403 | +expected: false, |
| 404 | +}, |
390 | 405 | { |
391 | 406 | name: "keeps strict mode for non-http URLs", |
392 | 407 | url: "file:///tmp/input.txt", |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -127,7 +127,7 @@ export function shouldUseEnvHttpProxyForUrl(
|
127 | 127 | * matches (kept in sync with that behavior) |
128 | 128 | * - Subdomain suffix match (`openai.com` matches `api.openai.com`) |
129 | 129 | * - Optional `:port` suffix; when present, must match target port |
130 | | - * - IPv6 literals in bracketed form (`[::1]`) |
| 130 | + * - IPv6 literals in bracketed (`[::1]`) or bare (`::1`) form |
131 | 131 | * - OpenClaw extension: IPv4 CIDR and octet-wildcard entries |
132 | 132 | * (`100.64.0.0/10`, `100.64.*`) bypass the trusted env proxy mode before |
133 | 133 | * undici's EnvHttpProxyAgent is selected. |
@@ -187,10 +187,15 @@ export function matchesNoProxy(targetUrl: string, env: NodeJS.ProcessEnv = proce
|
187 | 187 | entryHost = m[1]; |
188 | 188 | entryPort = m[2]; |
189 | 189 | } else { |
190 | | -const colonIdx = entry.lastIndexOf(":"); |
191 | | -if (colonIdx > 0 && /^\d+$/.test(entry.slice(colonIdx + 1))) { |
192 | | -entryHost = entry.slice(0, colonIdx); |
193 | | -entryPort = entry.slice(colonIdx + 1); |
| 190 | +const firstColonIdx = entry.indexOf(":"); |
| 191 | +const lastColonIdx = entry.lastIndexOf(":"); |
| 192 | +if ( |
| 193 | +firstColonIdx > -1 && |
| 194 | +firstColonIdx === lastColonIdx && |
| 195 | +/^\d+$/.test(entry.slice(lastColonIdx + 1)) |
| 196 | +) { |
| 197 | +entryHost = entry.slice(0, lastColonIdx); |
| 198 | +entryPort = entry.slice(lastColonIdx + 1); |
194 | 199 | } else { |
195 | 200 | entryHost = entry; |
196 | 201 | } |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。