Skip to content
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

Added to obtain the remote IP client #49

Closed
wants to merge 2 commits into from
Closed

Added to obtain the remote IP client #49

wants to merge 2 commits into from

Conversation

dmitriyshx
Copy link

No description provided.

@housleyjk
Copy link
Owner

Thank you for the PR!

This appears to duplicate functionality with Handshake::remote_addr. Can you give me the reasoning behind adding this? I can't say I like the idea of adding a public field to the Sender. Please elaborate.

@dmitriyshx
Copy link
Author

dmitriyshx commented May 30, 2016

It's not exactly duplicate.
Function Handshake::remote_addr in windows does not return remote ip.
This option get the remote ip from TcpListener::accept, that guarantees a real data.

@housleyjk
Copy link
Owner

Ok, so this is really a Windows issue. I don't want to make a duplicate API for getting something where one approach doesn't work on Windows and the other does. I think that will be confusing. Instead, I would like to find a way to provide a solution that works on both Windows and Unixy systems. Does Handshake::local_addr work for you on Windows?

@dmitriyshx
Copy link
Author

In Windows Handshake::local_addr and Handshake::peer_addr is empty.

Get IP from forwarded without proxies is not true.

@dmitriyshx
Copy link
Author

dmitriyshx commented May 30, 2016

Possible Sender::addr move to Handshake::peer_addr and add a method Handshake::forwarded_ip for old method get ip. How about this implementation?

@housleyjk
Copy link
Owner

Ok, it looks like this failure exists in Mio, so I've created an issue there tokio-rs/mio#397. Hopefully, if this can be fixed in Mio, you should be able to get the peer_addr, local_addr, and remote_addr (which checks the forwarded header) in Windows the same as they work in Linux currently. This gist demonstrates the issue https://gist.github.com/housleyjk/fa0ab22ef2264818c43d25ab2ed76ffb. If the issue can't be fixed in Mio, I will investigate other options to resolve this problem in WS-RS (although I don't know if it will be possible to resolve more than the peer_addr). For, now, I'm going to close this PR because the current API should provide what you need, it's just broken on Windows and an upstream fix should fix it for you.

@housleyjk housleyjk closed this May 30, 2016
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.

None yet

2 participants