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

addr::remote filter doesn't work with Server::run_incoming #428

Closed
tedsta opened this issue Jan 29, 2020 · 2 comments
Closed

addr::remote filter doesn't work with Server::run_incoming #428

tedsta opened this issue Jan 29, 2020 · 2 comments

Comments

@tedsta
Copy link

tedsta commented Jan 29, 2020

Hi! I have a (perhaps ugly / misguided) use-case where I need to get at the underlying file descriptor of each incoming WebSocket so that I can pass it to libc to get the linux-specific send-q stat - how much unacknowledged data is in the queue.

A solution to my use-case is to store the file descriptor of each incoming socket in a HashMap<SocketAddr, RawFd> using TryStreamExt::inspect_ok. This works as long as one can get the SocketAddr of the connection from inside the warp filters.

Unfortunately that's not currently possible, because run_incoming wraps everything in LiftIo, which always returns None for Transport::remote_addr().

A solution to this is to expose Transport and run_incoming2 (probably under a new name) so that people can implement Transport for their own types and pass it directly to run_incoming2.

@tedsta tedsta changed the title Expose Transport and Server::run_incoming2? remote_addr filter doesn't work with Server::run_incoming Feb 21, 2020
@tedsta tedsta changed the title remote_addr filter doesn't work with Server::run_incoming addr::remote filter doesn't work with Server::run_incoming Feb 26, 2020
@jxs
Copy link
Collaborator

jxs commented Jul 8, 2020

Hi, have you seen the filter to service conversion?
also see #16 (comment), make_service_fn receives AddrStream which implements Transport

@tedsta
Copy link
Author

tedsta commented Jul 14, 2020

Oh cool! That almost works for me, but AddrStream does not implement AsRawFd. The underlying tokio::net::TcpStream does, but AddrStream doesn't provide any way to get at it with a borrowed &AddrStream (and no way to convert a tokio::net::TcpStream back into an AddrStream even if it were owned). I think that solves my use-case as far as warp is concerned though, I'll have to take the AsRawFd issue to hyper. Thanks.

I still feel that it is a bit of a wart that there is no way to make warp::addr::remote() work in a situation where it is technically possible.

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

No branches or pull requests

2 participants