banditcallback: forward client IP via True-Client-IP#669
Merged
Conversation
Without this, the API-side handleArmCallback derives ASN/country from the request's source IP, which is the proxy VPS's egress — not the device. Per-ASN blocking signals were keyed to the hosting ASN (Linode/OCI/Hetzner) rather than the client's ISP, so the data fed into selection-time scoring never matched the (country, asn) keys the selector reads back. Filter.Apply now pulls the client IP from req.RemoteAddr (same source opsfilter uses for measured reporting) and passes it to EmitIfFirstSeen, which sets True-Client-IP on the outbound callback when non-empty. Empty clientIP omits the header entirely so the API's existing RemoteAddr fallback path stays intact. The per-arm token already authenticates the caller as a provisioned proxy daemon, so trusting True-Client-IP on the arm-callback endpoint is safe. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The arm-callback emitter introduced in #668 fires
GET /v1/bandit/callback?token=arm-…&did=…from the proxy VPS. The API-side handler resolves ASN/country from the request's source IP via MaxMind — but the source IP is the VPS's egress (Linode/OCI/Hetzner), not the device's. Per-ASN blocking signals on the lantern-cloud side were keyed to the hosting ASN, so the data fed into selection-time scoring never matched the(country, asn)keys the selector reads back. Effectively dead data.Caught in Copilot review on lantern-cloud#2792.
What
Filter.Applypulls client IP fromreq.RemoteAddr(same sourceopsfilteruses for measured reporting)EmitIfFirstSeen(ctx, deviceID, clientIP)— clientIP is forwarded asTrue-Client-IPheader when non-emptyTrue-Client-IPon the arm-callback endpoint is safe (consumer-side trust gate lands in lantern-cloud#2792)Test plan
go test ./banditcallback/...— passes (existing tests + newTestEmitter_OmitsTrueClientIPWhenEmpty;TestEmitter_FirstSeenFiresasserts the header lands)go build ./http-proxy/— binary compilesbandit_vps_http_proxy_default_short_tagTrue-Client-IP: <device IP>;bandit:blocking-signals:*keys land under the device's ASN, not the VPS's🤖 Generated with Claude Code