-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add remote ip field to Http::Request #453
Comments
Should probably differentiate between the IP the TCP connection came from and things like the |
http server implementation is surprisingly simple and it was easy to write own TCP socket loop
It works great. |
I'm currently using the following method: https://github.com/jhass/carc.in/blob/master/src/web.cr#L96-L102 But A proper solution should fallback to the sockets peer ip afterwards. |
It was easy to implement my own version of the server as in the comment above. This issue might be closed now if devs think |
We'll soon take a look at this with @waj, as it seems this is very needed :-) |
To be picky, the remote_ip should be associated with the connection, not the request. Though, use-wise it would be both more convenient and logical on the request object. |
|
If you're using crystals behind nginx, you should be able to get the remote ip with
I'm using dokku with the heroku buildpack and this seems to work fine. |
Luckily since I run everything behind a load balancer, I am able to, by way of headers, obtain a remote IP. That being said, it would be nice to have fields, perhaps a The distinction between the two being that |
See also #1722 |
Given that this functionality is requested quite often (it has come up a few times on Gitter in the past weeks) and there is a working implementation in #1722, I wonder how this could be pushed forward? |
I'm trying to build a proxy server in crystal and need to add my own |
I'd really like to see this move on and I don't know why this couldn't be implemented by a non-core member. It's actually not that big of a deal I think. One hold-up was the question where the remote IP should be stored but it seems that |
I've been thinking about this. While I generally agree, there seems a flaw in this approach: It makes This makes me wonder if it wouldn't be better to retrieve the address at initialization and store it in an ivar. It adds a little performance penalty, but is more fault tolerant and reduces overall complexity. |
It is useful to get access from
HTTP::Handler
to underlying socket properties. I am interested in the client ip address (aka 'remote_ip'). CurrentlyHttp::Request
has fields that are parsed out of the request body but no client ip.The text was updated successfully, but these errors were encountered: