Skip to content
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

Remove square brackets from ipv6 addresses in XFF #2182

Merged
merged 3 commits into from Nov 24, 2022

Conversation

42wim
Copy link
Contributor

@42wim 42wim commented May 16, 2022

Some loadbalancers (eg citrix ADC / netscaler) add square brackets around the ipv6 address in the X-Forwarded-For header.
This PR removes them so that RealIP() and friends work correctly.

Copy link
Contributor

@aldas aldas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not understand why this change is only applied to IPs related to XForwardedFor. There are couple of more functions that could extract headers with square brackets.

context.go Show resolved Hide resolved
ip.go Outdated Show resolved Hide resolved
@42wim
Copy link
Contributor Author

42wim commented May 21, 2022

I do not understand why this change is only applied to IPs related to XForwardedFor. There are couple of more functions that could extract headers with square brackets.

Because netscaler only uses XForwardedFor, but I'll modify it for the others too if needed.

@42wim
Copy link
Contributor Author

42wim commented May 21, 2022

  • ReplaceAll removed
  • support for XRealIP added
  • tests added

@42wim 42wim requested a review from aldas August 6, 2022 15:28
Copy link
Contributor

@aldas aldas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything other than this one comment (of missing strings.TrimSpace at `context.RealIP) is OK and I'll merge it when this is fixed.

context.go Show resolved Hide resolved
@42wim 42wim requested a review from aldas September 2, 2022 22:02
@42wim
Copy link
Contributor Author

42wim commented Nov 22, 2022

@aldas i've fixed it a while ago, any more remarks about this PR?

@aldas
Copy link
Contributor

aldas commented Nov 24, 2022

I am sorry for the delay. I often forget to recheck PRs

Copy link
Contributor

@aldas aldas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LTGM

@aldas aldas merged commit 7544796 into labstack:master Nov 24, 2022
@aldas aldas mentioned this pull request Dec 27, 2022
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.

None yet

2 participants