mirror of
https://github.com/jasonxu114514/opencode2api.git
synced 2026-12-05 08:02:53 +00:00
The WARP pool could never rotate: its lifetime context was derived from the startup deadline, so every standby registration and replacement died with "context canceled" and requests stayed on the first egress forever. Give the first registration the caller's deadline and the pool a context that only Close cancels. - warp.pool_size is an upper bound. The active ring follows concurrency (one exit per lease, one per queued request, plus a spare) and trims idle surplus after 60 seconds, so a burst expands it and quiet periods shrink it. - An IPv6 exit is deduplicated and cooled by its /64 for 30 minutes (IPv4 by its /32), since the free quota is scoped to that block. - 429/403 retires an exit immediately and re-registers right away; a free model request keeps switching exits and only returns the last 429 after retry.max_attempts, on both the anonymous and the Zen-key lane. 429s no longer trip the anonymous breaker or cool the key. - Pin HTTP/1.1 ALPN and TLSNextProto on the WARP transport: a clone of DefaultTransport made after its first dial negotiated h2 and fed SETTINGS frames to the HTTP/1.x reader, breaking catalog refresh. - Default to the IPv6 stack and, with warp.source_ipv6, let each exit bind its own outer source from a routed prefix via IPV6_FREEBIND. Endpoints try IPv6 first and fall back to IPv4, so IPv4-only hosts keep working. - WebUI, config example and all READMEs describe the new pool and rotation behaviour.
24 lines
776 B
Go
24 lines
776 B
Go
//go:build linux
|
|
|
|
package warp
|
|
|
|
import "syscall"
|
|
|
|
// ipv6FREEBIND is IPV6_FREEBIND (Linux 2.6.22+), which lets a socket bind an
|
|
// IPv6 source address that is routed to this host but not assigned to an
|
|
// interface. golang.org/x/sys/unix does not export the constant yet.
|
|
const ipv6FREEBIND = 78
|
|
|
|
// freebindControl permits binding an outer source address from the configured
|
|
// prefix. Without it the kernel refuses every address the host did not assign
|
|
// to an interface, which is the normal case for a routed /64.
|
|
func freebindControl(_, _ string, raw syscall.RawConn) error {
|
|
var sockErr error
|
|
if err := raw.Control(func(fd uintptr) {
|
|
sockErr = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IPV6, ipv6FREEBIND, 1)
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
return sockErr
|
|
}
|