Initial implementation: clean-room domain fronting library#1
Merged
Conversation
Clean-room rewrite of github.com/getlantern/fronted with architectural improvements: no global state, context-driven lifecycle, atomic config swaps, channel-based ready queue, and minimal dependencies (utls + go-yaml only). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a new standalone Go module (github.com/getlantern/domainfront) implementing a clean-room domain fronting client library, including config parsing (gzipped YAML), front candidate pooling, uTLS-based TLS dialing/cert verification, an HTTP RoundTripper, caching, and supporting unit tests plus README documentation.
Changes:
- Added
Clientlifecycle with background crawler, cache saver, and optional remote config updater. - Implemented config model + parsing/expansion (host alias lookup, passthrough patterns, per-country SNI selection).
- Added front pool (Take/Return/Replace), uTLS dialing/cert verification, request rewriting/round-trip logic, and JSON file cache; included unit tests and README.
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
domainfront.go |
Core Client, options, crawler, cache saver, config updater, config helpers |
config.go |
Config/Provider/Masquerade types, gzip+YAML parsing, provider expansion and lookup |
front.go |
Front candidate state + pool implementation (Replace/Take/Return/candidates) |
dialer.go |
Dialer abstraction + uTLS-based TLS dialing and certificate verification |
roundtrip.go |
http.RoundTripper implementation, request rewriting, connection transport wrapper |
sni.go |
Deterministic SNI selection from arbitrary list using hash |
cache.go |
Cache interface + file-backed JSON cache + cached-state application |
fileutil.go |
File read/write helpers used by FileCache |
README.md |
Package documentation, usage, options, architecture notes |
*_test.go |
Unit tests for config, SNI, dialer/cert verification, pool behavior, and client lifecycle |
go.mod / go.sum |
New module definition and dependency lockfiles |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Split Return/ReturnSuccess: Return(requeue) no longer updates LastSucceeded; only ReturnSuccess marks a real success. Dial failures always call Return(false). - applyConfig returns error: New() fails fast if config has no providers or malformed CA certs. CertPool() now returns (*x509.CertPool, error). - Clamp crawlerConcurrency >= 1 to prevent zero-capacity semaphore deadlock. - fetchAndApplyConfig uses http.NewRequestWithContext(c.ctx) so shutdown cancels in-flight config fetches. - ParseConfigFromReader limits input to maxConfigSize (50 MB). - rewriteRequest sets r.Host = originHost so the CDN sees the real destination in the Host header, not the fronted domain. - Request body buffered for retries via GetBody or io.ReadAll fallback. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Runs build and tests with -race on every push to main and PR. Co-Authored-By: Claude Opus 4.6 (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.
Summary
Clean-room rewrite of
github.com/getlantern/frontedas a new standalone package with significant architectural improvements:*Client, logger injected via optioncontext.Contexteverywhere — single context controls all goroutines;Close()cancels itfrontPool.Replace()swaps candidates while preserving state from previously-working fronts (no unbounded append)selectinTake(), nosync.Condor goroutine-per-callutls+go-yaml(eliminatedkeepcurrent,pond,ops)DialerandCacheinterfaces; pipe-based mock TLS servers, no real CDN hitsFile layout
domainfront.goconfig.gofront.godialer.goroundtrip.gosni.gocache.gofileutil.goAccepts the same config format
The library reads the same
fronted.yaml.gz(gzipped YAML withtrustedcasandproviderssections) used by the existingfrontedpackage — drop-in config compatibility.Test plan
🤖 Generated with Claude Code