mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-16 13:05:14 +03:00
fix(cli): keep loopback requests off environment proxies (#60441)
Co-authored-by: r266-tech <r266-tech@users.noreply.github.com> Co-authored-by: pj.reid <pj.reid@zetier.com>
This commit is contained in:
committed by
GitHub
Unverified
parent
ef712d3a78
commit
78dda62d88
@@ -19,6 +19,19 @@ import { Heap } from "./heap"
|
||||
import { CpuProfile } from "./cpu-profile"
|
||||
import { ShutdownDeadline } from "./shutdown-deadline"
|
||||
|
||||
// Keep requests to the local service off any proxy. Bun reads lowercase `no_proxy` alone whenever it is set, so both
|
||||
// spellings get the same merged list.
|
||||
const noProxy = [
|
||||
...new Set(
|
||||
[process.env.NO_PROXY, process.env.no_proxy, "127.0.0.1,localhost,::1"].flatMap((value) =>
|
||||
(value ?? "").split(",").flatMap((entry) => entry.trim() || []),
|
||||
),
|
||||
),
|
||||
].join(",")
|
||||
|
||||
process.env.NO_PROXY = noProxy
|
||||
process.env.no_proxy = noProxy
|
||||
|
||||
ensurePluginRuntime()
|
||||
|
||||
if (process.env.OPENCODE_SSH_ASKPASS_PORT) {
|
||||
|
||||
@@ -70,18 +70,16 @@ const loadSystemCertificates = Effect.try({
|
||||
catch: (error) => error,
|
||||
}).pipe(Effect.catch((error) => Effect.logWarning("failed to load system certificates", { error })))
|
||||
|
||||
// Bun reads lowercase `no_proxy` alone whenever it is set, so both spellings get the same merged list.
|
||||
function ensureLoopbackNoProxy() {
|
||||
const loopback = ["127.0.0.1", "localhost", "::1"]
|
||||
const noProxy = [
|
||||
...new Set(
|
||||
[process.env.NO_PROXY, process.env.no_proxy, "127.0.0.1,localhost,::1"].flatMap((value) =>
|
||||
(value ?? "").split(",").flatMap((entry) => entry.trim() || []),
|
||||
),
|
||||
),
|
||||
].join(",")
|
||||
|
||||
;["NO_PROXY", "no_proxy"].forEach((key) => {
|
||||
const items = (process.env[key] ?? "")
|
||||
.split(",")
|
||||
.map((value) => value.trim())
|
||||
.filter(Boolean)
|
||||
|
||||
loopback.forEach((host) => {
|
||||
if (!items.some((value) => value.toLowerCase() === host)) items.push(host)
|
||||
})
|
||||
process.env[key] = items.join(",")
|
||||
})
|
||||
process.env.NO_PROXY = noProxy
|
||||
process.env.no_proxy = noProxy
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user