fix(proxy): probe the OpenCode origin instead of cloudflare.com (#153)

Co-authored-by: local <local@local>
This commit is contained in:
Quheng Dengandlocal authored and GitHub committed 2026-11-05 11:41:13 +08:00
1 parent 58f56676ba
commit 079cd7b434
2 files changed
+16 -2

No files matched your search

+9 -1
View File
@@ -548,7 +548,15 @@ func (p *proxyTransports) checkClaimedProxy(ctx context.Context, proxy *proxyTra
req, err := http.NewRequestWithContext(checkCtx, http.MethodGet, target, nil)
if err == nil {
req.Header.Set("User-Agent", httpx.V2UserAgent())
resp, requestErr := proxy.client.Do(req)
// Probe with the same client free-model traffic uses. The Bun client
// reproduces the official OpenCode client's TLS fingerprint, so a probe
// through it measures the path it judges instead of a plain Go TLS
// handshake that some origins treat differently.
probeClient := proxy.client
if proxy.bun != nil {
probeClient = proxy.bun
}
resp, requestErr := probeClient.Do(req)
err = requestErr
if resp != nil {
_, _ = io.Copy(io.Discard, io.LimitReader(resp.Body, 64<<10))
+7 -1
View File
@@ -12,7 +12,13 @@ import (
)
const (
proxyHealthCheckURL = "https://cloudflare.com/cdn-cgi/trace"
// The probe answers "can this exit serve traffic?", so it targets the
// OpenCode origin itself. cloudflare.com is an unrelated third party that
// proxy providers routinely block or rate-limit on their egress, so exits
// that serve OpenCode fine were disabled and eventually retired by a probe
// that never touched OpenCode. checkClaimedProxy counts any HTTP response
// as success, so a 404 from the origin still proves the tunnel reaches it.
proxyHealthCheckURL = "https://opencode.ai/"
proxyHealthCheckInterval = 15 * time.Minute
proxyHealthCheckTimeout = 10 * time.Second
)