Skip to content

Allow callers to override smart_dialer_config.yml#35

Merged
myleshorton merged 2 commits into
mainfrom
fisk/configurable-smart-config
May 16, 2026
Merged

Allow callers to override smart_dialer_config.yml#35
myleshorton merged 2 commits into
mainfrom
fisk/configurable-smart-config

Conversation

@myleshorton
Copy link
Copy Markdown
Contributor

Summary

Follow-up to #34. Lets callers replace the embedded smart_dialer_config.yml so a custom StreamDialer plumbed via WithStreamDialer is actually exercised by the smart strategy.

Why

The embedded config lists system: {} first under DNS. When the Outline-SDK strategy picks the system resolver (which it does whenever the probe path doesn't fail), it enforces this check at smart/stream_dialer.go:350:

if resolver == nil {  // resolver == nil means "system: {}" was selected
    if _, ok := f.StreamDialer.(*transport.TCPDialer); !ok {
        return nil, fmt.Errorf("cannot use system resolver with base dialer of type %T", f.StreamDialer)
    }
}

So any caller that supplies a StreamDialer that isn't exactly *transport.TCPDialer — e.g. radiance's bypass dialer, which is a FuncStreamDialer wrapping bypass.DialContext — sees the smart dialer fail at construction. findFallback is then called and errors out with "no fallback was specified" because the kindling config has no FALLBACK section.

Semantically this constraint is correct: system: {} uses the OS resolver, which routes through OS routing tables. For radiance, that means through its own VPN TUN — defeating the entire purpose of bypass. The strategy's type check is honest: "if you're using system DNS, you can't also be doing custom transport routing."

The fix is to let callers swap in a config that omits system: {} (using DoH/DoT entries that go through the StreamDialer) when they pass a custom dialer.

Changes

  • WithSmartDialerConfig([]byte) Option — overrides the embedded YAML for the WithProxyless path. Order-independent with the other dialer options (same deferred-construction pattern as Allow callers to plug a custom dialer into the smart strategy #34).
  • NewSmartHTTPTransportWithConfig(...) — same override for the standalone helper used by radiance/kindling/smart. NewSmartHTTPTransportWithDialer is preserved (delegates to the new helper with nil config).
  • Empty-config validation matching the rest of the option family.
  • Test coverage:
    • ProxylessConfigOrderIndependent — config supplied before and after WithProxyless reaches newSmartDialerFn.
    • WithSmartDialerConfig_Empty_ReturnsError — nil and empty []byte both rejected at option time.

Test plan

  • go test ./... passes (existing ProxylessDialerOrderIndependent test updated for the new newSmartDialerFn signature)
  • Radiance branch using NewSmartHTTPTransportWithConfig + a system-less YAML resolves the smart strategy through the bypass dialer — to be verified once this lands and radiance bumps the dep

🤖 Generated with Claude Code

The embedded smart_dialer_config.yml lists `system: {}` first under DNS,
which makes the Outline-SDK strategy fall back to the OS resolver. The
strategy then requires the base StreamDialer to be exactly
*transport.TCPDialer (smart/stream_dialer.go:350), rejecting any other
type with "cannot use system resolver with base dialer of type %T".

Callers passing a custom StreamDialer that isn't *transport.TCPDialer
(notably radiance's bypass dialer, which is a FuncStreamDialer) need to
also supply a strategy config that omits `system: {}` so the strategy
routes every probe through their dialer.

Adds:
- WithSmartDialerConfig([]byte) Option for the WithProxyless path
- NewSmartHTTPTransportWithConfig() for the standalone helper path
- Empty-config validation matching the rest of the option family
Copilot AI review requested due to automatic review settings May 16, 2026 11:59
Copy link
Copy Markdown
Contributor

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 adds support for overriding the embedded smart dialer YAML config so callers using custom dialers can avoid the default system: {} resolver path.

Changes:

  • Adds WithSmartDialerConfig([]byte) for WithProxyless.
  • Adds NewSmartHTTPTransportWithConfig(...) for standalone smart transport construction.
  • Updates tests for deferred config plumbing and empty config rejection in the option path.

Reviewed changes

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

File Description
kindling.go Adds smart dialer config plumbing through options and standalone transport helper.
kindling_test.go Updates smart dialer test hook signature and adds config-order/empty-config tests.

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

Comment thread kindling.go
Comment thread kindling.go
- NewSmartHTTPTransportWithConfig now rejects non-nil empty slices,
  matching WithSmartDialerConfig's strictness. Prevents a callers'
  `make([]byte, 0)` mistake from silently skipping the embedded default
  and handing outline-sdk empty YAML.
- Add TestNewSmartHTTPTransportWithConfig with three subtests:
  config arg plumbed through, nil → embedded fallback, empty → error.
  Closes the gap Copilot flagged: prior tests only covered the
  WithProxyless option path.
@myleshorton myleshorton merged commit a9712f9 into main May 16, 2026
1 check passed
@myleshorton myleshorton deleted the fisk/configurable-smart-config branch May 16, 2026 12:08
myleshorton added a commit to getlantern/lantern that referenced this pull request May 16, 2026
Pulls in getlantern/radiance#485, which routes kindling smart-strategy
probes through the bypass dialer so kindling traffic doesn't loop back
through the VPN TUN. Transitively bumps kindling to a9712f9
(getlantern/kindling#35) for the WithSmartDialerConfig surface.
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