Skip to content

peer: route the peer-box sing-box logger into radiance's slog#481

Open
myleshorton wants to merge 1 commit into
fisk/peer-connection-eventsfrom
fisk/peer-box-logger
Open

peer: route the peer-box sing-box logger into radiance's slog#481
myleshorton wants to merge 1 commit into
fisk/peer-connection-eventsfrom
fisk/peer-box-logger

Conversation

@myleshorton
Copy link
Copy Markdown
Contributor

Summary

The second sing-box instance the peer client spins up was constructed with a plain `box.BaseContext()` and no sing-box log factory registered. That means router / dial / outbound errors from the peer-box landed on the box's default stderr logger and never reached `lantern.log` — which made the SmC verify-failure incident triaged today unnecessarily hard.

We had:

  • `[samizdat] CONNECT api.iantem.io:443: handler started` at `20:41:35.079`
  • `[samizdat] CONNECT api.iantem.io:443: handler returned, starting drain` at `20:41:35.096` — 17 ms later
  • Then 5 s of drain timeout and 1475 bytes of the verifier's TLS ClientHello discarded
  • Server-side: `peer verify failed: verify round-trip through peer: Get "https://api.iantem.io/v1/peer/verify-callback?token=...\": EOF`

The peer's sing-box outbound dial to `api.iantem.io` failed almost instantly — but with zero error log anywhere in either `lantern.log` or `lantern_macos.log`. The `i.logger.ErrorContext(ctx, err)` at `lantern-box/protocol/samizdat/inbound.go:178` would have caught the underlying error, but the peer-box's logger output goes to a default stderr destination instead of slog.

Change

Mirror what `vpn/tunnel.go:141-142` already does for the main tunnel's box — register `lblog.NewFactory(slog.Default().Handler())` as the `sblog.Factory` on the peer-box's context before `NewServiceWithContext`. sing-box logger output now flows through radiance's slog and into `lantern.log` alongside everything else.

Test plan

  • `go build ./peer/...` passes
  • `go test -count=1 ./peer/...` passes (existing peer tests still green)
  • Next SmC toggle that triggers a verify failure should now produce a sing-box-side error log line in `lantern.log` explaining the actual dial failure — that's the signal we were missing today.

Stack note

Branched off `fisk/peer-connection-events` because the peer module lives there. Will rebase onto main once the peer module merges.

🤖 Generated with Claude Code

The second sing-box instance the peer client spins up was constructed
with a plain box.BaseContext() and no sing-box log factory registered.
That means router / dial / outbound errors from the peer-box landed
on the box's default stderr logger and never reached lantern.log —
which made the recent SmC verify-failure incident (FD #174614)
unnecessarily hard to triage. The verifier's CONNECT handler returned
within 17 ms with no error log anywhere in the lantern logs; the
"why did api.iantem.io fail to dial?" answer was just silently
swallowed.

Mirror what vpn/tunnel.go:141-142 already does for the main tunnel's
box — register lblog.NewFactory(slog.Default().Handler()) as the
sblog.Factory on the peer-box's context before NewServiceWithContext.
sing-box logger output now flows through radiance's slog and into
lantern.log alongside everything else.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 14, 2026 21:42
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 routes the peer client’s secondary sing-box instance logging through Radiance’s slog pipeline so peer-box router/dial/outbound errors reach lantern.log.

Changes:

  • Adds sing-box service/log imports and lantern-box log factory import.
  • Registers an sblog.Factory on the peer box context before creating the libbox service.

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

Comment thread peer/peer.go
Comment on lines +624 to +626
// peer-share verify failure — which made FD #174614 unnecessarily
// hard to triage. Mirrors vpn/tunnel.go's registration for the
// main tunnel's box.
Comment thread peer/peer.go
// hard to triage. Mirrors vpn/tunnel.go's registration for the
// main tunnel's box.
ctx := box.BaseContext()
service.MustRegister[sblog.Factory](ctx, lblog.NewFactory(slog.Default().Handler()))
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