-
Notifications
You must be signed in to change notification settings - Fork 207
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
Incorrect handling of IPv6 addresses in some configurations #56
Comments
An alternative solution (besides commenting out that method to strip out what's after the colon) ... might be to allow the user to provide a BOOL variable in the configuration to say the port is not included. |
The fix in f2c85b5 isn't going to work: https://play.golang.org/p/ugnk527u-b As seen here,
|
I'm a bit surprised that you decided to ignore the error from that method, as well. That's a really bad idea. |
What about this?
This will cover ipv4, ipv6 with port, and ipv6 without port. |
Looking at the code for the method: https://golang.org/src/net/ipsock.go?s=4746:4812#L145 ... It appears that might work. Although it seems a bit delicate considering that new errors could be introduced, currently the two "unexpected" errors I see at first glance are:
... Those seem to account for the two cases that the port is missing from either address format? |
For comparison, here's how Gin handles this on App Engine and the like: https://github.com/gin-gonic/gin/blob/9a4ecc87d6f8272b8e2450f9c0ab12d3e814521f/context.go#L514 |
... Would it be possible to just pass in the IP somehow externally? |
I can cover the app engine as well. If you want to pass in IP, you can already do so by using |
I mean as a struct parameter. |
Do you always expect the same ip addresses? |
No, just thinking aloud about ideas. For example, if there is already code that the user has to get the IP for a request based on their configuration, it would be helpful to override. |
I see, a function hook seems like a decent idea to let user pick up IP address however they want. I need to think about it a bit more. In the mean time, I pushed the ipv6 change under |
Created: didip/tollbooth_gin#4 |
Hi, I noticed that this library (along with others) assumes that the port number is always provided in
http.Request.RemoteAddr
... Because this is an incorrect assumption, this breaks IPv6 on such installations where the port number is NOT provided: https://play.golang.org/p/oFZhZ6BCf3
Code to demonstrate issue
Result:
It's probably necessary to validate the IPv6 address first in order to detect if the port is not there. There is actually a pretty bad bug since a lot of App Engine deployments might be using this as-is and Google has no intention of changing this "portless" behavior.
The text was updated successfully, but these errors were encountered: