-
-
Notifications
You must be signed in to change notification settings - Fork 226
feat(cmd/anubis): compute full XFF header #328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
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
this one is pretty important to not pass through blindly, as many applications and frameworks will trust them
Xe
approved these changes
Apr 23, 2025
Perfect. This should work nicely. Thanks much! |
compilade
reviewed
Apr 24, 2025
Comment on lines
+74
to
+83
remoteIP, _, err := net.SplitHostPort(r.RemoteAddr) | ||
|
||
if parsedRemoteIP := net.ParseIP(remoteIP); parsedRemoteIP != nil && parsedRemoteIP.IsLoopback() { | ||
// anubis is likely deployed behind a local reverse proxy | ||
// pass header as-is to not break existing applications | ||
return | ||
} | ||
|
||
if err != nil { | ||
slog.Warn("The default format of request.RemoteAddr should be IP:Port", "remoteAddr", r.RemoteAddr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using unix
sockets with the BIND
config option, it seems like r.RemoteAddr
is always @
and so this always warns with something like
{"time":"2025-04-23T12:00:00.000000000-00:00","level":"WARN","source":{"function":"main.main.XForwardedForUpdate.func5","file":"github.com/TecharoHQ/anubis/internal/headers.go","line":83},"msg":"The default format of request.RemoteAddr should be IP:Port","remoteAddr":"@"}
acuteaura
added a commit
to acuteaura/anubis
that referenced
this pull request
Apr 24, 2025
TecharoHQ#328 followup now featuring configuration and defaults that shouldn't break most setups. fixes TecharoHQ#344
Xe
added a commit
that referenced
this pull request
Apr 25, 2025
* feat: more elaborate XFF compute #328 followup now featuring configuration and defaults that shouldn't break most setups. fixes #344 * refactor: obvious condition eval order optimization * feat: add StripLLU implementation * chore: I'm sorry it's 7 AM * test: add test environment for unix socket serving Signed-off-by: Xe Iaso <me@xeiaso.net> * test(unix-socket-xff): comment out the shell script more Signed-off-by: Xe Iaso <me@xeiaso.net> * fix(internal): fix logic bug in XFF computation, add tests Signed-off-by: Xe Iaso <me@xeiaso.net> * fix(internal): prevent panic in local testing Signed-off-by: Xe Iaso <me@xeiaso.net> * fix(internal): shuffle around return values to flow better Signed-off-by: Xe Iaso <me@xeiaso.net> --------- Signed-off-by: Xe Iaso <me@xeiaso.net> Co-authored-by: Xe Iaso <me@xeiaso.net>
JasonLovesDoggo
pushed a commit
to JasonLovesDoggo/anubis
that referenced
this pull request
Jun 17, 2025
* feat(cmd/anubis): compute full XFF header this one is pretty important to not pass through blindly, as many applications and frameworks will trust them * feat(cmd/anubis): skip XFF compute if remote address is loopback * docs: update CHANGELOG
JasonLovesDoggo
pushed a commit
to JasonLovesDoggo/anubis
that referenced
this pull request
Jun 17, 2025
* feat: more elaborate XFF compute TecharoHQ#328 followup now featuring configuration and defaults that shouldn't break most setups. fixes TecharoHQ#344 * refactor: obvious condition eval order optimization * feat: add StripLLU implementation * chore: I'm sorry it's 7 AM * test: add test environment for unix socket serving Signed-off-by: Xe Iaso <me@xeiaso.net> * test(unix-socket-xff): comment out the shell script more Signed-off-by: Xe Iaso <me@xeiaso.net> * fix(internal): fix logic bug in XFF computation, add tests Signed-off-by: Xe Iaso <me@xeiaso.net> * fix(internal): prevent panic in local testing Signed-off-by: Xe Iaso <me@xeiaso.net> * fix(internal): shuffle around return values to flow better Signed-off-by: Xe Iaso <me@xeiaso.net> --------- Signed-off-by: Xe Iaso <me@xeiaso.net> Co-authored-by: Xe Iaso <me@xeiaso.net>
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.
Checklist:
[Unreleased]
section of docs/docs/CHANGELOG.mdnpm run test:integration
(unsupported on Windows, please use WSL)