diff --git a/internal/gateway/pool.go b/internal/gateway/pool.go index a7182c9..2e98859 100644 --- a/internal/gateway/pool.go +++ b/internal/gateway/pool.go @@ -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)) diff --git a/internal/gateway/refresh.go b/internal/gateway/refresh.go index f20a5bc..d90420c 100644 --- a/internal/gateway/refresh.go +++ b/internal/gateway/refresh.go @@ -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 )