Skip to content

config: add Aliyun (Alibaba Cloud) CDN domain-fronting provider#10

Merged
myleshorton merged 7 commits into
mainfrom
fisk/aliyun-provider
Jun 24, 2026
Merged

config: add Aliyun (Alibaba Cloud) CDN domain-fronting provider#10
myleshorton merged 7 commits into
mainfrom
fisk/aliyun-provider

Conversation

@myleshorton

@myleshorton myleshorton commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

What

Add Alibaba Cloud (Aliyun) CDN as a domain-fronting provider — a third option alongside CloudFront and Akamai.

Stacked on #9 (HTTP/2 fronting). Aliyun negotiates h2 under the Chrome ClientHello, so the live test depends on that PR. Review/merge #9 first; this PR's base will retarget to main automatically once #9 lands.

Why Aliyun works for fronting

Aliyun CDN edges route purely on the HTTP Host header (HTTP/1.1) / :authority (HTTP/2) and ignore the TLS SNI for origin selection — the unrestricted domain-fronting behavior CloudFront/Google/Akamai removed in 2018. A censor doing SNI filtering sees only an innocent front domain (img.alicdn.com, core Taobao infrastructure that's costly to block).

Verified 2026-06-23 (US vantage), cross-organization: a TLS session presenting Alibaba's *.tbcdn.cn certificate (SNI img.alicdn.com) reached the origins of three unrelated companies purely via Host:

SNI (cert) Host: Edge served
img.alicdn.com (Alibaba) www.taobao.com Taobao homepage, 200
img.alicdn.com (Alibaba) s1.hdslb.com (Bilibili) Bilibili OK, 200
img.alicdn.com (Alibaba) img.momocdn.com (Momo) Momo origin (x-tos-* headers)

What's in the file

aliyun-provider.yaml is a complete, ParseConfigYAML-able Config (so it loads standalone for testing); the aliyun: block is what merges into the upstream fronted pipeline output.

  • trustedcas — GlobalSign Root CA - R3, which anchors the Alibaba leaf chain (*.tbcdn.cn → GlobalSign GCC R3 OV TLS CA 2024 → R3). Confirmed to verify the live chain.
  • frontingsnis.defaultimg/gw/a.alicdn.com, all covered by the shared *.tbcdn.cn cert and provisioned CDN-wide.
  • masquerades — a verified seed pool of edge IPs across three /24s, each confirmed to present the Alibaba cert.

⚠️ Placeholders requiring follow-up

hostaliases and testurl are REPLACE-ME placeholders. Two boundary conditions make this unavoidable today:

  1. The target Host must be an onboarded Aliyun CDN customer — a non-customer Host (e.g. www.example.com) is silently dropped. So Lantern must create its own Aliyun CDN distributions and map real origins to them.
  2. testurl must return 202 on POST (the verifyWithPost vetting contract), which only a Lantern-controlled distribution can satisfy.

Mapping real domains + the masquerade harvesting belong in the lantern-cloud config-generation pipeline (tracked separately).

Test plan

aliyun_live_test.go (guarded by DOMAINFRONT_LIVE=1; skipped in CI). Against the real Aliyun CDN, through the library's real roundTripper:

TLS+verify OK: ip=155.102.54.138 sni=img.alicdn.com alpn=h2 (cert chained to config's GlobalSign root)
fronted s1.hdslb.com via 155.102.54.138 (SNI img.alicdn.com, h2): HTTP 200, proto=HTTP/2, body="OK"
... (all 6 edges) ...
PASS

i.e. every edge completes TLS + GlobalSign verification under the production Chrome_131 hello and fronts Bilibili over HTTP/2.

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features

    • Added a standalone Alibaba (Aliyun) CDN domain-fronting configuration, including a pinned trusted certificate chain for TLS validation and enforced hostname verification.
    • Added SNI-driven fronting behavior and edge masquerade mappings to support successful HTTPS routing (including HTTP/2 when negotiated).
  • Tests

    • Added an end-to-end live integration test (enabled only when explicitly configured) to validate TLS+verification, confirm successful HTTPS responses, and verify HTTP/2 negotiation.

Copilot AI review requested due to automatic review settings June 23, 2026 03:53
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 19c8c4c5-b65d-489c-89e2-be6b9f89e60b

📥 Commits

Reviewing files that changed from the base of the PR and between 669b4d4 and fd616da.

📒 Files selected for processing (1)
  • aliyun-provider.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
  • aliyun-provider.yaml

📝 Walkthrough

Walkthrough

Adds aliyun-provider.yaml, a standalone Alibaba CDN domain-fronting provider configuration with a pinned CA, host aliases, fronting SNIs, and seed masquerade IPs. Also adds aliyun_live_test.go, a live integration test gated on DOMAINFRONT_LIVE that parses the config, dials real Aliyun edge IPs, and asserts HTTP 200 and HTTP/2 negotiation.

Changes

Aliyun CDN Domain-Fronting Provider

Layer / File(s) Summary
Aliyun provider YAML configuration
aliyun-provider.yaml
Introduces the complete provider config: operational comments, a pinned GlobalSign/Alibaba TLS root CA PEM, hostaliases mapping *.getiantem.org services to accelerated Aliyun domains, a POST testurl for runtime vetting, verifyhostname set to img.alicdn.com, frontingsnis listing three *.alicdn.com SNI candidates, and a seed masquerades list mapping img.alicdn.com to fixed Aliyun edge IP addresses.
Live integration test
aliyun_live_test.go
Adds TestAliyunProviderLive, gated on DOMAINFRONT_LIVE, which loads and parses aliyun-provider.yaml, builds a cert pool from the config's GlobalSign root, expands the aliyun provider for country "cn", dials each masquerade via dialFront with utls.HelloChrome_131, issues an HTTP GET to cross-org host s1.hdslb.com via roundTripper.doRequest, and asserts at least one HTTP 200 response and at least one HTTP/2 (h2) negotiation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • getlantern/domainfront#9: The live test added here directly exercises roundTripper.doRequest and validates HTTP/2 negotiation (proto == "h2" / resp.ProtoMajor == 2), which corresponds to the ALPN/HTTP-2 transport changes introduced in that PR.

Poem

🐇 Hops across the Great Divide,
Through Aliyun's CDN edge I glide,
SNI whispered, cert verified,
HTTP/2 streams run side by side,
The domain fronting rabbit can't be denied! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately summarizes the main change: adding Alibaba Cloud (Aliyun) CDN as a new domain-fronting provider, which is the primary objective of the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fisk/aliyun-provider

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an Aliyun (Alibaba Cloud) CDN provider configuration and an opt-in live test to validate end-to-end domain-fronting against real Aliyun edges (including TLS chain verification and ALPN-negotiated HTTP/2 behavior, when enabled via env var).

Changes:

  • Added aliyun-provider.yaml as a standalone ParseConfigYAML-compatible config containing Aliyun provider settings (trusted root, SNI selection, and seed masquerade IPs).
  • Added aliyun_live_test.go, an opt-in (DOMAINFRONT_LIVE=1) live network test that loads the YAML, expands provider SNIs, dials edges using the library’s TLS path, and attempts a cross-org fronted request.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
aliyun-provider.yaml Introduces Aliyun provider YAML config (trusted CA, fronting SNIs, host alias placeholders, masquerade seed list).
aliyun_live_test.go Adds an opt-in live test that exercises Aliyun provider config against real CDN edges using the library’s dial/roundtrip path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread aliyun-provider.yaml Outdated
Comment thread aliyun-provider.yaml Outdated
Comment thread aliyun_live_test.go

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comment thread aliyun-provider.yaml
Comment thread aliyun_live_test.go
Comment thread aliyun_live_test.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment thread aliyun-provider.yaml Outdated
Comment thread aliyun_live_test.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment thread aliyun_live_test.go Outdated
Comment thread aliyun_live_test.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment thread aliyun-provider.yaml Outdated
Comment thread aliyun-provider.yaml Outdated
Base automatically changed from fisk/h2-fronting to main June 24, 2026 00:42
myleshorton and others added 5 commits June 23, 2026 19:18
Alibaba Cloud / Aliyun CDN edges route by the HTTP Host header (h1) /
:authority (h2) and ignore the TLS SNI for origin selection, so a censor
filtering on SNI sees only an innocent front domain (img.alicdn.com) while
the request reaches the real target. Verified 2026-06-23 cross-organization:
a TLS session bearing Alibaba's *.tbcdn.cn cert (SNI img.alicdn.com) reached
Bilibili (s1.hdslb.com) and Momo (img.momocdn.com) origins purely by Host.

This adds aliyun-provider.yaml: a complete, parseable Config with the
GlobalSign Root CA - R3 (anchors the Alibaba leaf chain), a verified seed
pool of edge IPs across three /24s, and frontingsnis driving img/gw/a
.alicdn.com SNIs. hostaliases + testurl are placeholders until Lantern
origins are onboarded as Aliyun CDN distributions (the edge silently drops
non-customer Host values).

aliyun_live_test.go (guarded by DOMAINFRONT_LIVE=1) drives the real
roundTripper: every edge completes TLS + GlobalSign verification under the
production Chrome_131 hello and fronts a cross-org Host over HTTP/2 (200).

Depends on #9 (HTTP/2 fronting) — Aliyun negotiates h2.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…guard test

- Set provider-level verifyhostname: img.alicdn.com so the SNI path enforces
  leaf hostname verification instead of chain-only (which would accept any
  GlobalSign-R3-chained cert). All masquerade edges serve Alibaba's *.tbcdn.cn
  cert (SAN *.alicdn.com), so the single value validates every rotating
  frontingsni (img/gw/a.alicdn.com).
- Drop per-masquerade sni/verifyhostname: ExpandedProvider ignores them
  (it propagates the provider-level values), so listing them was misleading.
- Guard the live test with require.Contains before indexing Providers["aliyun"]
  to fail clearly instead of a nil-deref panic if the key changes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…olders

- The live test counted any HTTP 200 as success even if ALPN had fallen back
  to http/1.1, so it didn't actually prove the HTTP/2 fronting path. Now
  require that at least one cross-org front succeeded with proto=="h2" and an
  HTTP/2 response (frontedOverH2).
- Lowercase the REPLACE-ME placeholder hostnames (replace-me.w.kunlunaq.com):
  ExpandedProvider doesn't lowercase alias values, and lowercase matches the
  README examples and avoids case-sensitive host routing surprises.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Check the http.NewRequestWithContext and io.ReadAll errors instead of
discarding them; require a clean body read before counting a front as
successful, so a truncated/failed response can't be miscounted.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace the REPLACE-ME placeholders with the real Aliyun DCDN accelerated
domains, now created and validated end-to-end (2026-06-23): fronting each via
img.alicdn.com returns byte-identical responses to the canonical origin.

  config.getiantem.org  -> config.dcdn.getiantem.org
  api.getiantem.org     -> api.dcdn.getiantem.org
  geo.getiantem.org     -> geo.dcdn.getiantem.org
  update.getlantern.org -> update.dcdn.getiantem.org

The hostalias value is the accelerated domain (the fronted Host), not the
*.w.kunlungr.com edge CNAME — the edge vhosts on the accelerated domain.
Each distribution is overseas-scope, origin = the raw iantem.io backend
(bypassing Cloudflare) with back-to-origin SNI = origin and Host = service
domain. testurl notes the 202-ping follow-up.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@myleshorton myleshorton force-pushed the fisk/aliyun-provider branch from 35e8508 to 5547e86 Compare June 24, 2026 01:20

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@aliyun_live_test.go`:
- Around line 78-84: The close operations for res.conn and resp.Body are
ignoring their returned errors, which can hide I/O teardown issues and will fail
errcheck validation. Capture the error return values from both res.conn.Close()
at line 78 and resp.Body.Close() at line 84, then handle these errors
appropriately by either logging them with t.Logf or asserting they are nil using
error checks or if statements to ensure any close errors are properly reported
in the test output.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: bdf2e63f-017e-4b90-8834-092851e0fcc8

📥 Commits

Reviewing files that changed from the base of the PR and between 9359174 and 5547e86.

📒 Files selected for processing (2)
  • aliyun-provider.yaml
  • aliyun_live_test.go

Comment thread aliyun_live_test.go Outdated
Capture and log the errors from res.conn.Close() and resp.Body.Close()
in TestAliyunProviderLive rather than discarding them, matching the
test's existing t.Logf diagnostics and satisfying errcheck.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 24, 2026 01:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread aliyun-provider.yaml
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 24, 2026 01:37
@myleshorton myleshorton merged commit b304b2f into main Jun 24, 2026
2 of 3 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread aliyun-provider.yaml
Comment on lines +61 to +63
# NOTE: These hostaliases and testurl are real, validated mappings.
# aliyun_live_test.go reads this file directly; if you intend placeholders,
# update the PR description and replace these with clearly marked REPLACE-ME values.
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