backend, vpn: integrate lantern-box MutableAutoSelect outbound#492
Draft
garmr-ulfr wants to merge 2 commits into
Draft
backend, vpn: integrate lantern-box MutableAutoSelect outbound#492garmr-ulfr wants to merge 2 commits into
garmr-ulfr wants to merge 2 commits into
Conversation
Adapts radiance to consume the new MutableAutoSelect outbound from lantern-box (PR #266). Replaces the prior MutableURLTest selector with one that distinguishes probe-URL health from user-traffic health. - Build `auto` as TypeMutableAutoSelect with per-tag bandit URL overrides. The demote / dedupe / proved-read knobs inherit documented lantern-box defaults. - Bridge the group's ExhaustionSignal onto a vpn.ExhaustionEvent so subscribers can react without the tunnel knowing about them. LocalBackend subscribes and refetches /config-new through an exhaustionGate that rate-limits to one minute. - Register a lantern-box AutoSelectHistoryStorage on the tunnel and run a ticker-coalesced flush listener that mirrors per-tag TagHistory snapshots (probe scalars + user_failures window) into the persisted servers file. Lifecycle tied to Connected/ Disconnected VPN status events. - Seed cold-start ranking via the offline URL-test path: results are shaped as TagHistory entries and persisted so the next tunnel start picks them up via SelectionHistorySeed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates Radiance’s VPN tunnel and backend integration to use lantern-box’s new MutableAutoSelect outbound, including persisting per-tag selection/probe history and emitting an exhaustion signal to trigger rate-limited config refetches.
Changes:
- Replace the previous URL-test selector/history path with
MutableAutoSelect+ per-tagTagHistorypersistence and seeding. - Bridge
MutableAutoSelectexhaustion signaling into avpn.ExhaustionEvent, and add a backend refetch gate (1/min) on exhaustion. - Update CLI/server models to surface selection history (and latest latency derived from it) instead of
urlTestResult.
Reviewed changes
Copilot reviewed 15 out of 18 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
vpn/vpn.go |
Switch tunnel startup to pass SelectionHistorySeed; tighten offline URL-test outbound lookup/type checks. |
vpn/types.go |
Add AutoSelectHistoryStorage alias and new ExhaustionEvent type. |
vpn/tunnel.go |
Register lantern-box AutoSelectHistoryStorage, seed it, and emit exhaustion events from the auto group. |
vpn/session_history.go |
Formatting/alignment only. |
vpn/clash.go |
Formatting changes; still pulls adapter.URLTestHistoryStorage from context. |
vpn/boxoptions.go |
Build TypeMutableAutoSelect outbound and add SelectionHistorySeed to BoxOptions. |
vpn/boxoptions_test.go |
Update bandit override test to assert MutableAutoSelect options type. |
servers/manager.go |
Persist selection history (TagHistory) per server instead of urlTestResult; rename JSON field to selection_history. |
cmd/lantern/vpn.go |
Filter group tags from throughput output; derive displayed latency from selection history. |
cmd/lantern/servers.go |
Replace urlTestResult output with selection_history/latest-success delay. |
cmd/lantern/monitor.go |
Update pool summary to incorporate selection history and avoid group-tag phantom throughput entries. |
config/config.go |
Rename ConfigHandler.Update() to Fetch(). |
backend/radiance.go |
Listen for selection-history changes and persist snapshots; add exhaustion-triggered config refetch with rate limiting; seed tunnel from persisted history; shape offline URL-test results into TagHistory. |
backend/radiance_test.go |
Remove empty placeholder test. |
backend/exhaustion_test.go |
Add unit test for exhaustion refetch rate-limiting gate. |
go.mod / go.sum |
Bump github.com/getlantern/lantern-box dependency for MutableAutoSelect. |
AGENTS.md |
Update example comment text to match renamed listener. |
Comments suppressed due to low confidence (1)
servers/manager.go:146
- UnmarshalJSON only reads the new selection_history field; any existing persisted servers files from older versions that contain urlTestResult will silently drop prior latency data on upgrade. Consider accepting the legacy urlTestResult field in serverJSON and converting it into a TagHistory snapshot during unmarshal to preserve cold-start ranking/history across upgrades.
func (s *Server) UnmarshalJSON(data []byte) error {
sj, err := json.UnmarshalExtendedContext[serverJSON](box.BaseContext(), data)
if err != nil {
return err
}
s.Tag = sj.Tag
s.Type = sj.Type
s.IsLantern = sj.IsLantern
s.Location = sj.Location
s.Credentials = sj.Credentials
s.SelectionHistory = sj.SelectionHistory
if sj.Outbound != nil {
s.Options = *sj.Outbound
} else if sj.Endpoint != nil {
s.Options = *sj.Endpoint
}
return nil
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Server.Clone deep-copies SelectionHistory (including UserFailures) so AllServers and GetServerByTag callers can't alias the Manager's shared state. The clashServer's unused urlTestHistory field is removed, and HistoryStorage now returns nil to satisfy adapter.ClashServer. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Adapts radiance to consume the new MutableAutoSelect outbound from lantern-box (PR #266). Replaces the prior MutableURLTest selector with one that distinguishes probe-URL health from user-traffic health.
autoas TypeMutableAutoSelect with per-tag bandit URL overrides. The demote / dedupe / proved-read knobs inherit documented lantern-box defaults.