Skip to content

Commit

Permalink
fix(transport): Add Connected impl for TcpStream (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-a-cliqz authored and LucioFranco committed Jan 20, 2020
1 parent 6de0b4d commit cfdf0af
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tonic/src/transport/server/conn.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::transport::Certificate;
use hyper::server::conn::AddrStream;
use std::net::SocketAddr;
use tokio::net::TcpStream;
#[cfg(feature = "tls")]
use tokio_rustls::{rustls::Session, server::TlsStream};

Expand All @@ -27,6 +28,12 @@ impl Connected for AddrStream {
}
}

impl Connected for TcpStream {
fn remote_addr(&self) -> Option<SocketAddr> {
self.peer_addr().ok()
}
}

#[cfg(feature = "tls")]
impl<T: Connected> Connected for TlsStream<T> {
fn remote_addr(&self) -> Option<SocketAddr> {
Expand Down

0 comments on commit cfdf0af

Please sign in to comment.