Skip to content

Remove tlsdialer dependency#69

Merged
myleshorton merged 4 commits intomainfrom
remove-tlsdialer-dependency
Mar 19, 2026
Merged

Remove tlsdialer dependency#69
myleshorton merged 4 commits intomainfrom
remove-tlsdialer-dependency

Conversation

@myleshorton
Copy link
Contributor

@myleshorton myleshorton commented Mar 19, 2026

Summary

  • Inlines the TLS dial logic from tlsdialer/v3 directly into front.go, replacing the single call site with ~20 lines of utls.UClient usage
  • Reuses the existing verifyPeerCertificate for manual cert verification on the non-SNI path, keeping verification consistent across both paths
  • Drops tlsdialer and its transitive deps (mtime, netx, golog, errors, hidden, hex, iptool, bpool, zap, multierr) — net removal of ~100 lines from go.sum
  • Fixes TestVerifyPeerCertificate which was failing due to expired Akamai certs, and adds DigiCert Global Root G3 to DefaultTrustedCAs for the new cert chain

Why

tlsdialer wraps utls with DNS resolution, timeout management, and cert verification — most of which fronted doesn't need since it passes pre-resolved IPs and handles its own cert verification via VerifyPeerCertificate. Inlining the needed logic simplifies the dependency tree.

Test plan

  • TestDomainFrontingWithoutSNIConfig passes
  • TestVerifyPeerCertificate passes (updated certs + expiry skip guard)
  • TestPassthrough, TestHostAliasesBasic, TestHostAliasesMulti pass
  • TestDomainFrontingWithSNIConfig skipped in CI (pre-existing; real Akamai endpoints unreliable from CI runners)

🤖 Generated with Claude Code

tlsdialer wrapped utls with DNS resolution, timeout management, and
cert verification — most of which fronted doesn't need since it
passes pre-resolved IPs and handles its own cert verification via
VerifyPeerCertificate. This inlines the ~25 lines of actually needed
logic (UClient creation, handshake with deadline, manual cert
verification for non-SNI path) and drops tlsdialer plus its
transitive deps (mtime, netx).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes the tlsdialer/v3 dependency by inlining the minimal uTLS dialing logic directly into front.go, including a new helper for manual certificate verification on the non-SNI path, and updates module files to drop the removed dependency tree.

Changes:

  • Remove github.com/getlantern/tlsdialer/v3 usage and inline uTLS dial + handshake logic in front.go.
  • Add verifyServerCerts helper to perform manual x509 verification when SNI is not used.
  • Clean up go.mod/go.sum to drop tlsdialer and related transitive dependencies.

Reviewed changes

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

File Description
front.go Replaces tlsdialer with inline uTLS dial/handshake logic and adds manual cert verification helper.
go.mod Removes tlsdialer/v3 and prunes indirect dependencies.
go.sum Removes checksums for dropped dependencies after module tidy.

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

myleshorton and others added 3 commits March 19, 2026 16:18
…root

The test used hardcoded Akamai certs that expired 2026-03-18. Updated
with fresh certs (valid until 2026-12-22) which chain through DigiCert
Global G3 (new intermediate), so added the DigiCert Global Root G3 CA
to DefaultTrustedCAs. Also added an early skip guard that parses the
leaf cert expiry so future expiration produces a clear skip message
instead of a cryptic failure.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Return conn (*tls.UConn) instead of conn.Conn (*tls.Conn); both do
  encrypted I/O but returning the UConn directly is cleaner.
- Remove verifyServerCerts helper and reuse the existing
  verifyPeerCertificate function from fronted.go, eliminating
  duplicate verification logic between SNI and non-SNI paths.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Two issues caused this test to fail intermittently:

1. defaultFrontedProviderID was a package-level global mutated by
   tests, leaking state between them. Added WithDefaultProviderID
   option so each test sets its provider ID on its own Fronted
   instance instead of mutating the global.

2. The embedded config loads akamai fronts which get added alongside
   the test's cloudfront fronts. When an akamai front was randomly
   picked, the akamai provider lacked the test host mappings, causing
   "no domain fronting mapping" errors. Fixed by registering test
   hosts with the akamai provider in testProvidersWithHosts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@myleshorton myleshorton merged commit cf2160f into main Mar 19, 2026
1 check passed
@myleshorton myleshorton deleted the remove-tlsdialer-dependency branch March 19, 2026 22:52
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