Add ClientIp extractor and migrate handlers#428
Conversation
ee7d3b2 to
4da9771
Compare
4da9771 to
3b8df39
Compare
0976c05 to
edc7bd9
Compare
edc7bd9 to
b0b15dc
Compare
|
Update after the force-push:
Local validation performed:
Constraints / caveats:
|
|
Quick update on the rerun for this PR (#428): the current red is That is a different failure from the earlier I’m not planning to make further changes to #428 unless a failing test points to a concrete issue in the PR itself, so from my side the remaining options are either rerunning to see whether the failure reproduces or merging #429 and closing out/superseding this PR. |
|
I'm sorry for not addressing this sooner. These flakes are not your fault and no further action has been required. I sincerely appreciate your effort here 🙏🏻 and I'll be attending to this very shortly. If in any case there is a delay and (considering the broad scope of the diff) a conflict forms, I will take responsibility for resolving that. Thank you! 🫡 |
Summary
Introduces a tuwunel-internal
ClientIpextractor insrc/api/client_ip.rsand migrates all 22 API handler call sites away fromaxum_client_ip::InsecureClientIp.This change is plumbing only. It is designed to be a no-op for every existing deployment:
InsecureClientIp, preserving today's header scan chain andConnectInfofallback exactly.ConfiguredIpSource, gates theSecureClientIpbranch. Nothing in this change installs that marker; Add configurable ip_source for client IP resolution. #429 installs it only whenip_sourceis configured.SecureClientIpSource::ConnectInfoextension installed bysrc/router/layers.rsis intentionally untouched and ignored by this extractor, so Unix-socket deployments (Unix listener can't read client ip #310) remain unaffected.Two-PR series
This is the first PR in a two-PR effort for configurable, spoofing-resistant client IP resolution:
ClientIpextractor and migrates handlers to use it, while preserving current behavior by default.ip_sourceconfig field, startup warnings for trusted-proxy header sources, reload protection, router-layer installation ofConfiguredIpSource, and deployment documentation.Keeping this split lets reviewers verify the mechanical extractor migration independently from the user-facing configuration and documentation work. #429 should land after this PR.
Test plan
cargo check -p tuwunel_apicargo clippy -p tuwunel_api --no-deps -- -D warningsrustup run nightly rustfmt --checkon touched filescargo test -p tuwunel_api client_ipsrc/api/client_ip.rscover fallback and configured paths, malformed headers, IPv6, XFF priority, configured-header absence, and the auto-installedSecureClientIpSourceregression./_matrix/client/versions, confirm tracing emits the connecting IP as today.