fronted: apply "default" SNI bucket when no country code is set#7
Conversation
`Provider::expanded` was ported from the old getlantern/fronted country-code rule, which gated the SNIConfig lookup behind a non-empty country code. The newer getlantern/domainfront deliberately removed that gate so the "default" arbitrary-SNI bucket applies to the production client, which passes no country code. Without this, the new first-class `aliyun` provider — whose only frontingsnis bucket is "default" (usearbitrarysnis: true) — would dial Aliyun CDN edges with an empty SNI, losing the img.alicdn.com camouflage that lets the edge serve its *.tbcdn.cn certificate. The fronted dial would then fail certificate verification. Match domainfront::ExpandedProvider exactly: - an empty country code now selects the "default" bucket (an unknown non-empty code still falls back to "default" as before); - a generated arbitrary SNI takes precedence, but a per-masquerade SNI baked into the config is preserved rather than clobbered with an empty string. Add regression tests for the aliyun-shaped default-bucket-with-empty-CC case and for baked-in masquerade SNI preservation. Verified the real domainfront/fronted.yaml.gz (with the aliyun provider) parses end-to-end. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EztFQJYZxiWTk2PQwo9qWh
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesFronting SNI expansion behavior
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Summary
flint-fronted::Provider::expandedwas ported from the oldgetlantern/frontedcountry-code rule, which gates the SNIConfig lookup behind a non-empty country code. The newergetlantern/domainfrontdeliberately removed that gate (seedomainfront/config.go::ExpandedProvider, whose comment spells out why) so the"default"arbitrary-SNI bucket applies to the production client, which passes no country code.This bites the brand-new first-class
aliyunprovider indomainfront/fronted.yaml.gz(providers: akamai, aliyun, cloudfront). Aliyun's onlyfrontingsnisbucket isdefaultwithusearbitrarysnis: true(img.alicdn.com/gw.alicdn.com/a.alicdn.com). Under the old gate, an empty country code selected no SNIConfig →generate_snireturned""→ flint dialed Aliyun edges with no SNI, losing the*.tbcdn.cn-cert guarantee (aliyun-provider.yamlconstraint #1: "the edge node must hold a cert valid for the SNI you present.img.alicdn.comis ideal"). The fronted dial then fails certificate verification.Root cause (the wrong branch fires)
sequenceDiagram autonumber participant App as Client<br/>no country code participant Pool as FrontPool::new<br/>flint-fronted/lib.rs participant Exp as Provider::expanded<br/>flint-fronted/lib.rs:123 participant Gen as generate_sni<br/>flint-fronted/lib.rs:1082 participant Conn as connect_with<br/>flint-tls/connector.rs:107 participant Edge as Aliyun CDN edge App->>Pool: dial config.fetch with country_code = "" Pool->>Exp: expanded("") rect rgba(255, 200, 200, 0.3) Note over Exp: BEFORE — country_code.is_empty so sni_cfg = None ⚠️ 🐛 end Exp->>Gen: generate_sni(None, ip) Gen-->>Exp: "" empty SNI Exp-->>Pool: masquerade.sni = "" Pool->>Conn: boring_chrome(addr, sni="") Conn->>Edge: ClientHello with NO SNI Edge-->>Conn: default cert, not *.tbcdn.cn Conn-->>App: certificate verification FAILS Note over App,Edge: AFTER — get("") falls back to "default" bucket ✅ Note over Gen: returns img.alicdn.com so the edge serves *.tbcdn.cn and verify passesFix
Match
domainfront::ExpandedProviderexactly:"default"bucket (an unknown non-empty code still falls back to"default"as before);snibaked into the config is preserved rather than clobbered with an empty string.Tests
default_sni_bucket_applies_with_empty_country_code— the aliyun-shapeddefault-bucket-with-empty-CC case (would have failed before).baked_in_masquerade_sni_is_preserved_without_arbitrary_snis— per-masquerade pinned SNI survives expansion.domainfront/fronted.yaml.gz(with thealiyunprovider) parses end-to-end via the gatedparses_real_lantern_fronted_configtest.cargo test -p flint-frontedgreen (24 pass),cargo clippy/cargo fmtclean.Why this matters
This unblocks routing spark's config-fetch / cold-start bootstrap through
flint-kindling's fronted transport using the Alibaba Cloud provider — the production client passes no country code, so without this fix the alibaba fronting would be silently inert.🤖 Generated with Claude Code
https://claude.ai/code/session_01EztFQJYZxiWTk2PQwo9qWh
Summary by CodeRabbit