Skip to content

feat(client): implement FastStart for early connection and background resolver discovery - #205

Open
taskkillstar wants to merge 9 commits into
masterking32:mainfrom
taskkillstar:feat/fast-start-resolvers
Open

feat(client): implement FastStart for early connection and background resolver discovery#205
taskkillstar wants to merge 9 commits into
masterking32:mainfrom
taskkillstar:feat/fast-start-resolvers

Conversation

@taskkillstar

Copy link
Copy Markdown

Summary

When configured with large resolver lists (e.g. 50–100+ endpoints), the client previously blocked session initialization and local proxy (SOCKS5/DNS) startup until 100% of all resolvers were synchronously probed for MTU.

This PR introduces FastStart:

  • When \RECHECK_INACTIVE_SERVERS_ENABLED = true\ (default), the initial MTU test completes early as soon as a minimal working set of resolvers (\min(TotalResolvers, max(1, RX_TX_WORKERS))) is validated.
  • The client connects and opens local proxy listeners immediately (~1–2s startup time).
  • The remaining unscanned resolvers remain in the pool as \inactive, where the existing background
    unResolverHealthLoop\ discovers and reactivates them asynchronously without blocking user traffic.
  • When \RECHECK_INACTIVE_SERVERS_ENABLED = false, the legacy behavior is preserved (full 100% upfront scan).

Key Changes

  • **\internal/client/mtu.go**: Added early-exit condition to \RunInitialMTUTests\ bounded by \ argetValid, capped worker count during fast start, and added completion logs.
  • **\internal/client/fast_start_test.go**: Added comprehensive unit test suite (\TestRunInitialMTUTests_FastStartExitsEarly, \TestRunInitialMTUTests_FullScanWhenRecheckDisabled, \TestRunInitialMTUTests_FallbackWhenFewerResolversWork).
  • **\client_config.toml.simple\ & \README.MD**: Documented FastStart behavior under \RECHECK_INACTIVE_SERVERS_ENABLED.
  • Exported helper methods in \internal/config\ and \internal/udpserver\ (\DefaultClientConfig, \DefaultServerConfig, \Server.HandlePacket).

Verification

  • \go test -v ./internal/client -run TestRunInitialMTUTests\ -> PASS
  • \go test ./...\ -> PASS across all packages
  • \go build ./cmd/client && go build ./cmd/server\ -> PASS (clean build)

@taskkillstar

taskkillstar commented Aug 16, 2026

Copy link
Copy Markdown
Author

Minimizes startup time (no need to scan the entire resolvers list), allows to have several hundreds of resolvers in the list without sacrificing connection time.

Requested by FR #179

…speed qualification

- Add pipelined micro-burst speed prober to detect rate-limiting and burst packet loss
- Add candidate ranking score and top-N active pool selection (MAX_ACTIVE_RESOLVERS)
- Add initial balancer stat seeding (SeedBurstStats) and set Loss-Then-Latency (6) as default strategy
- Add micro-burst qualification on background inactive resolver reactivation
- Update client config, sample configs, and all 6 localized READMEs with full documentation
… resolvers for fast warm-start

- Preserved natural input order in LoadClientResolvers without forced sorting
- Added managed header block in client_resolvers.txt to persist top-performing resolvers across runs
- Added AUTO_SAVE_RANKED_RESOLVERS configuration option (default: true)
- Added Balancer.GetRankedEndpoints and Client.SaveRankedResolversToFile
- Auto-saves upon initial MTU test completion, pool optimization swaps, and graceful shutdown
- Added unit tests for order preservation, atomic file update, and endpoint ranking
- Synchronized documentation, CLI parameters, and samples across all README files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants