-
Notifications
You must be signed in to change notification settings - Fork 88
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
Support multiple IP addresses for http_x_forwarded_for
#45
base: master
Are you sure you want to change the base?
Conversation
5cf8f83
to
8e4ca23
Compare
"flag" | ||
"fmt" | ||
gonx "github.com/satyrius/gonx" |
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.
Why did you change it from relative path? It was very convenient for development.
- 1.3 | ||
- 1.4 | ||
- 1.5 | ||
- 1.12 |
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.
Sort versions alphabetically plz
parser.go
Outdated
@@ -19,6 +19,11 @@ type Parser struct { | |||
regexp *regexp.Regexp | |||
} | |||
|
|||
func getSpecialNginxRegexes() map[string]string { | |||
return map[string]string{ | |||
"http_x_forwarded_for": `[^, ]*(?:, [^, ]+)*`} |
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.
The formatting looks off on those lines above. Can you double check gofmt plz?
} else { | ||
re = strings.Replace(re, field[2]+field[4], regexp.QuoteMeta(field[1])+"(?P<"+field[2]+">[^"+terminateChar+"]*)"+regexp.QuoteMeta(field[3]+field[4]), 1) | ||
} | ||
} |
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.
For the patch above, please, consider adding more comments around to explain what's going on.
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) |
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.
Looks like code duplication, please, make it more readable.
@conradolega are you interested in wrapping this up? |
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.