8000 feat(cmd/anubis): compute full XFF header by acuteaura · Pull Request #328 · TecharoHQ/anubis · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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 3 commits into from
Apr 23, 2025

Conversation

acuteaura
Copy link
Contributor
@acuteaura acuteaura commented Apr 22, 2025

Checklist:

  • Added a description of the changes to the [Unreleased] section of docs/docs/CHANGELOG.md
  • Added test cases to the relevant parts of the codebase
  • Ran integration tests npm run test:integration (unsupported on Windows, please use WSL)

this one is pretty important to not pass
through blindly, as many applications and
frameworks will trust them
@acuteaura acuteaura marked this pull request as ready for review April 22, 2025 17:35
@Xe Xe enabled auto-merge (squash) April 23, 2025 04:03
@Xe
Copy link
Contributor
Xe commented Apr 23, 2025

Perfect. This should work nicely. Thanks much!

@Xe Xe merged commit 4e2c9de into TecharoHQ:main Apr 23, 2025
3 checks passed
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)
Copy link
Contributor

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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0