feat: add configurable IP egress strategy - #1
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f355fe71a3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if currentStrategy != input.OutboundStrategy { | ||
| err = s.mutate(r.Context(), change) | ||
| } else { | ||
| err = s.saveConfig(change) |
There was a problem hiding this comment.
Serialize the strategy comparison with the settings mutation
When two PUT /api/settings requests overlap, this comparison occurs before either mutate or saveConfig acquires mutationMu. For example, a request restoring auto can read the old auto value while another request is applying prefer_ipv6, then enter saveConfig after that apply and overwrite the business config without reapplying the core configuration. The stored setting and running/generated sing-box configuration then disagree until a later core apply, so select the apply path while holding the same mutation lock.
Useful? React with 👍 / 👎.
| if currentStrategy != input.OutboundStrategy { | ||
| err = s.mutate(r.Context(), change) |
There was a problem hiding this comment.
Enforce a newly lowered quota before restarting the core
When one settings request both changes the outbound strategy and lowers totalBytes below the already-recorded usage, routing it through mutate calls Core.Apply using the old QuotaExceeded state. The core is therefore restarted and may serve traffic before the later ReconcileQuota call notices the new limit and stops it; a quota-only update does not have this window. Compute/reconcile the quota against the new settings before allowing this strategy apply to restart sing-box.
Useful? React with 👍 / 👎.
What changed
domain_resolverconfiguration with a local DNS serverWhy
Some VPS IPv4 ranges retain stale geolocation even after moving to a US ASN, while the server IPv6 range is correctly identified. Preferring IPv6 lets dual-stack destinations see the accurate IPv6 location while preserving IPv4 fallback.
Safety and compatibility
autoValidation
go test ./...andgo test -race ./...go vet ./...and gofmt checksing-box 1.13.14 checkfor the generatedprefer_ipv6configuration