Repository navigation
feat(proxy): add keys_direct so keyed lanes can keep one stable exit IP - #113
Closed
WengeLiu101 wants to merge 1 commit into
Closed
WengeLiu101 wants to merge 1 commit into
WengeLiu101 wants to merge 1 commit into
Conversation
The keyed (Zen/Go) lanes share the proxy pool with the anonymous lane, so an account's egress IP changes from request to request as soon as more than one proxy is configured. Upstream may read that as suspicious, and an operator who points the gateway at a large scraped pool has no way to opt out: the anonymous lane needs rotation, the keyed lanes do not. Add keys_direct, a top-level boolean (default false, so existing behaviour is unchanged) that pins every key to the local egress. - config.EnsureDirect appends a "direct" entry when the configured list has none, since a proxyfile-only config has no direct transport. Without it the setting would silently degrade to "spread across the pool". - newTransportPool records which entry is direct (transportPool.directIndex, proxyTransport.direct). - newNodePool pins every key to it when enabled. - newAnonymousPool skips the direct entry: the anonymous lane exists to leave the local egress behind, and the free tier rate-limits it by IP. - Startup logs the mode, and warns rather than silently ignoring keys_direct if no direct egress could be arranged.
jasonxu114514
added a commit
that referenced
this pull request
Nov 29, 2026
Owner
|
已在 main 以 a0fbd6b 重新實作並驗證,本 PR 由該提交取代,將納入 v1.5.2。keys_direct 預設 false;明確 proxy_bindings(含 direct4/direct6)優先,未綁定手動 Key 固定直連且失敗不遷移。內部注入的直連不會加入匿名/自動 OAuth 路由,並修正混合部署的健康狀態判定。感謝提案;關閉舊分支而不直接合併。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The keyed (Zen/Go) lanes share the proxy pool with the anonymous lane:
newNodePoolround-robins keys overevery transport. As soon as an operator configures more than one proxy, an account's egress IP changes from
request to request. Upstream may read that as suspicious, and there is currently no way to opt out — short of
removing the proxies, which the anonymous lane needs for rotation.
The two lanes want opposite things:
Change
New top-level config key, off by default so existing behaviour is unchanged:
{ "keys_direct": true }When enabled, every key is pinned to the local egress:
config.EnsureDirect()appends adirectentry when the configured list has none. A config whose proxies allcome from
proxyfilehas no direct transport, and without this the setting would silently degrade to"spread across the pool" — a no-op that looks like it worked.
newTransportPoolrecords which entry is direct (transportPool.directIndex,proxyTransport.direct).newNodePool(..., direct bool)pins every key to that index.newAnonymousPool()skips the direct entry: the anonymous lane exists precisely to leave the local egressbehind, and the free tier rejects/limits it by IP, so trying it there would burn an attempt on most requests.
event=keys_direct, withdirect_index/transports), and warns insteadof silently ignoring the setting if no direct egress could be arranged.
Verification
Built and run locally with
proxies: []+ aproxyfileof two proxies (so the list contains nodirect):keys_direct: trueevent=keys_direct direct_index=2 transports=3gofmtclean,go vet ./...clean,go build ./cmd/opencode2apiclean,go test ./internal/...passes.Notes
#poolrotating-entry feature: that one changes what a single entry is, this one changeswhich entries the keyed lanes may use.
falsemeans no migration is needed and no existing deployment changes behaviour.