Is there a way to obtain the remote IP of the incoming request?
Would have imagined something like what actix-web does without going through the headers?
async fn echo_remote(mut ctx: Context<()>) -> String {
ctx.connection_info().remote().to_owned()
}
Related issue: https://github.com/rustasync/http-service/issues/25.
@milesgranger we definitely want to add this, but it requires wrangling Hyper into allowing us to access this value, which has proven to be slightly challenging.
Note from triage: we're still blocked on this by Hyper.
Any update on this?
Given that we're constructing our own TcpListener now, we could probably find a way to pass it through to the end-user (:
Haven't fixed this yet though.
I believe this can be closed now. There is now:
req.peer_addr()
https://github.com/http-rs/tide/blob/1797c0ed648dd2d28fda2e18d5432bd4eaf2150c/src/request.rs#L118
Not only is there Request::peer_addr, but there's also Request::remote, which includes some additional sources of that information when tide is running behind a reverse proxy:
/// Get the remote address for this request.
///
/// This is determined in the following priority:
/// 1. `Forwarded` header `for` key
/// 2. The first `X-Forwarded-For` header
/// 3. Peer address of the transport