Skip to content

Support multiple IP addresses for http_x_forwarded_for - #45

Open
conradolega wants to merge 1 commit into
satyrius:masterfrom
conradolega:fix-http-forwarded-for
Open

Support multiple IP addresses for http_x_forwarded_for#45
conradolega wants to merge 1 commit into
satyrius:masterfrom
conradolega:fix-http-forwarded-for

Conversation

@conradolega

Copy link
Copy Markdown

This improves upon #37 by fixing some errors, and rebases it on top of master.

I've also updated the CI job to run against 1.12. It should also pass against Go's tip version.

Fixes #36.

@conradolega
conradolega force-pushed the fix-http-forwarded-for branch from 5cf8f83 to 8e4ca23 Compare November 26, 2019 23:45
Comment thread example/common/common.go
gonx "../.."
"flag"
"fmt"
gonx "github.com/satyrius/gonx"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Why did you change it from relative path? It was very convenient for development.

Comment thread .travis.yml
- 1.3
- 1.4
- 1.5
- 1.12

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Sort versions alphabetically plz

Comment thread parser.go Outdated

func getSpecialNginxRegexes() map[string]string {
return map[string]string{
"http_x_forwarded_for": `[^, ]*(?:, [^, ]+)*`}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

The formatting looks off on those lines above. Can you double check gofmt plz?

Comment thread parser.go
} else {
re = strings.Replace(re, field[2]+field[4], regexp.QuoteMeta(field[1])+"(?P<"+field[2]+">[^"+terminateChar+"]*)"+regexp.QuoteMeta(field[3]+field[4]), 1)
}
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

For the patch above, please, consider adding more comments around to explain what's going on.

Comment thread parser.go
if specialRegex, found := specialNginxRegexes[field[2]]; found {
re = strings.Replace(re, field[2]+field[4], regexp.QuoteMeta(field[1])+"(?P<"+field[2]+">"+specialRegex+")"+regexp.QuoteMeta(field[3])+field[4], 1)
} else {
re = strings.Replace(re, field[2]+field[4], regexp.QuoteMeta(field[1])+"(?P<"+field[2]+">[^"+terminateChar+"]*)"+regexp.QuoteMeta(field[3]+field[4]), 1)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Looks like code duplication, please, make it more readable.

@satyrius

satyrius commented Sep 5, 2022

Copy link
Copy Markdown
Owner

@conradolega are you interested in wrapping this up?

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.

Space between IP Addresses in $http_x_forwarded_for

2 participants