Add configurable ip_source for client IP resolution.#429
Open
theredspoon wants to merge 2 commits intomatrix-construct:mainfrom
Open
Add configurable ip_source for client IP resolution.#429theredspoon wants to merge 2 commits intomatrix-construct:mainfrom
theredspoon wants to merge 2 commits intomatrix-construct:mainfrom
Conversation
c2b4a76 to
3d06e45
Compare
3662b90 to
e7a50bd
Compare
fdb0e1b to
c2e9842
Compare
c2e9842 to
ed9fd3d
Compare
Author
|
Update after the restack:
Local validation performed:
Constraints / caveats:
|
6 tasks
Author
|
#429 includes all of #428 plus the It passed the same Given that, my preferred path would be to merge #429 and close #428 as superseded. If you’d rather preserve the two-PR split, I’d appreciate a rerun of #428 so you can merge them in order if it comes back green. |
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.
Summary
Depends on #428 and should land after it.
Adds an optional
ip_sourceconfig field for selecting how tuwunel resolves the client IP used by rate limiting, logging, and security tooling.When
ip_sourceis unset, noConfiguredIpSourceextension is installed, so theClientIpextractor from #428 keeps the existingInsecureClientIpfallback behavior. Whenip_sourceis set, the router installs aConfiguredIpSourcemarker that maps to the selectedSecureClientIpSourcevariant.This also:
ip_source, because the router layer stack is built at startup;ip_sourceintuwunel-example.tomlwith a valid commented example;ip_sourceunset rather than settingconnect_info;config-example:directive, so fields can document an unset runtime default while emitting a valid example value;synclone assumptions in the macro helper path so the touched macro crate remains directly testable.Macro note
tuwunel-example.tomlis generated byconfig_example_generator, so a hand-edited example value would be overwritten on build. The new hiddenconfig-example:directive letsip_sourcekeep its honest runtime default (unset/None) while generating the valid sample#ip_source = "connect_info".The small
src/macros/mod.rsandsrc/macros/implement.rschanges remove existingsynclone assumptions that surfaced when adding direct tests for the generator behavior. They are included sotuwunel_macroscan be checked, tested, and linted directly with this PR.Before / after
Before:
InsecureClientIp;After:
ip_sourcepreserves the previous behavior;ip_source = "connect_info"uses the TCP peer address;rightmost_x_forwarded_forandcf_connecting_ipopt into the matching secure source and log a startup warning reminding operators to use a trusted reverse proxy;ip_sourcechanges until restart.Closes #427.
Test plan
git diff --checkrustup run nightly rustfmt --check src/macros/config.rs src/macros/implement.rs src/macros/mod.rs src/core/config/mod.rs src/core/config/check.rs src/router/layers.rscargo test -p tuwunel_macroscargo test -p tuwunel_core --no-default-features -- config::testscargo test -p tuwunel_router --no-default-features -- layers::testscargo check -p tuwunel_macroscargo clippy -p tuwunel_macros -- -D warningscargo check -p tuwunel_core --no-default-featurescargo check -p tuwunel_router --no-default-featurescargo clippy -p tuwunel_core --no-default-features -- -D warningscargo clippy -p tuwunel_core --no-default-features --tests -- -D warningscargo clippy -p tuwunel_router --no-default-features -- -D warningscargo clippy -p tuwunel_router --no-default-features --tests -- -D warningslychee docs/deploying/generic.md docs/deploying/reverse-proxy-caddy.md docs/deploying/reverse-proxy-nginx.md docs/deploying/reverse-proxy-traefik.md(31 links checked, 0 errors, 3 redirects)#ip_source = "connect_info"and does not regenerate to#ip_source = unset.On this local macOS checkout, router-targeted commands used
CPLUS_INCLUDE_PATH=/Library/Developer/CommandLineTools/SDKs/MacOSX15.2.sdk/usr/include/c++/v1because the localclang++installation did not find libc++ headers by default.