Repository: seanmonstar/warp (language: rust)

Issue:
https can not get it's remote address.
warp version
```
warp={ version = "0.2.2", features = ["tls"] }
```

```rust
 let routes = warp::any().and(warp::addr::remote()).map(|addr: Option<SocketAddr>|  format!("Hello, World! {:?}",addr) );

    warp::serve(routes)
        //.tls()
        //.cert_path("tls/cert.pem")
        //.key_path("tls/key.rsa")
        .run(([0, 0, 0, 0], 3030))
        .await;
```
using http it's work ok.

```rust
  let routes = warp::any().and(warp::addr::remote()).map(|addr: Option<SocketAddr>|  format!("Hello, World! {:?}",addr) );

    warp::serve(routes)
        .tls()
        .cert_path("tls/cert.pem")
        .key_path("tls/key.rsa")
        .run(([0, 0, 0, 0], 3030))
        .await;
```
using https can not get it's remote address.




Discussion / hints:
Hi, can you give more context of your case, what is the output with tls and what system are you running it with?

HI, I am having the same problem running a server on Windows with tls activated. The call to `warp::addr::remote()` with tls gives `None`. Without tls it works normally and gives a client's address.
yup confirmed, this was introduced when switching to `rust-tls`, i am going to look into this
thanks for reporting

Fix patch:
diff --git a/src/tls.rs b/src/tls.rs
index 7a73be724..ea8694e39 100644
--- a/src/tls.rs
+++ b/src/tls.rs
@@ -172,10 +172,7 @@ impl Read for LazyFile {
 
 impl Transport for TlsStream {
     fn remote_addr(&self) -> Option<SocketAddr> {
-        match self.state {
-            State::Handshaking(_) => None,
-            State::Streaming(ref stream) => Some(stream.get_ref().0.remote_addr()),
-        }
+        Some(self.remote_addr)
     }
 }
 
@@ -189,13 +186,16 @@ enum State {
 // TlsStream implements AsyncRead/AsyncWrite handshaking tokio_rustls::Accept first
 pub(crate) struct TlsStream {
     state: State,
+    remote_addr: SocketAddr,
 }
 
 impl TlsStream {
     fn new(stream: AddrStream, config: Arc<ServerConfig>) -> TlsStream {
+        let remote_addr = stream.remote_addr();
         let accept = tokio_rustls::TlsAcceptor::from(config).accept(stream);
         TlsStream {
             state: State::Handshaking(accept),
+            remote_addr,
         }
     }
 }


Test patch: