-
Notifications
You must be signed in to change notification settings - Fork 8k
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
Quick Fix c.ClientIP() Parse Error for TrustedProxies feature & NoMethod annotation #2832
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2832 +/- ##
=======================================
Coverage 98.75% 98.75%
=======================================
Files 41 41
Lines 3062 3063 +1
=======================================
+ Hits 3024 3025 +1
Misses 26 26
Partials 12 12
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
@menduo @zihengCat Please leave your review here to help fix this as soon as possible. This change will parse TrustedProxies and trust all proxies by default. |
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.
Great works.
@thinkerou @appleboy code review plz |
@Bisstocuz I gave the comment. |
directly initialization
@junikaii @menduo I think that directly giving it a absolute default value is more consistent. @xpunch mentioned this in #2692 :
This value means trust all IPs by default. |
directly initialization
gin.ListenAndServe doesn't support trusted proxies and ClientIP doesn't work bump gin down to 1.6.2 to mitigate temporarily will update gin once gin-gonic/gin#2832 is merged
@appleboy Hi, code review plz. After this PR merged, I will do some works and create a new PR to perfect
|
@thinkerou need your approval. |
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.
lgtm
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.
Nice solution, make trustedCIDRs
pass all IP addresses by changing its default value.
@Bisstocuz Could you make all CI unit tests passed? |
@zihengCat I'm checking it. This seems to have something to do with #2872 |
@appleboy @zihengCat @thinkerou @junikaii Test result: https://github.com/Bisstocuz/gin/actions/runs/1285966832 |
…ng r.Run() to run http server (#2832)
…ng r.Run() to run http server (gin-gonic#2832) (cherry picked from commit 6d75aba)
…ng r.Run() to run http server (gin-gonic#2832) (cherry picked from commit 6d75aba)
…ng r.Run() to run http server (gin-gonic#2832) (cherry picked from commit 6d75aba)
…ng r.Run() to run http server (gin-gonic#2832) (cherry picked from commit 6d75aba)
…ng r.Run() to run http server (#2832)
…ng r.Run() to run http server (gin-gonic#2832) (cherry picked from commit 6d75aba)
…ng r.Run() to run http server (#2832)
…ng r.Run() to run http server (#2832)
…ng r.Run() to run http server (gin-gonic#2832)
Related issues: #2791 #2697 #2814
Someone who not using
r.Run()
to run http server may meet this issue:c.ClientIP()
always returns the same IP for all clients because of calling ofprepareTrustedCIDRs()
ofTrustedProxies
feature.For example,
c.ClientIP()
always returns127.0.0.1
while using local reverse proxy.In
New()
: there is one definition:TrustedProxies: []string{"0.0.0.0/0"}
We can see this variable has default value, but
trustedCIDRs
doesn't have.So we just need to give a default value to
trustedCIDRs
.