-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0505dff
commit 3eb76ab
Showing
9 changed files
with
193 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use hyper::server::conn::AddrStream; | ||
use std::net::SocketAddr; | ||
#[cfg(feature = "tls")] | ||
use tokio_rustls::TlsStream; | ||
|
||
/// Trait that connected IO resources implement. | ||
/// | ||
/// The goal for this trait is to allow users to implement | ||
/// custom IO types that can still provide the same connection | ||
/// metadata. | ||
pub trait Connected { | ||
/// Return the remote address this IO resource is connected too. | ||
fn remote_addr(&self) -> Option<SocketAddr> { | ||
None | ||
} | ||
} | ||
|
||
impl Connected for AddrStream { | ||
fn remote_addr(&self) -> Option<SocketAddr> { | ||
Some(self.remote_addr()) | ||
} | ||
} | ||
|
||
#[cfg(feature = "tls")] | ||
impl<T: Connected> Connected for TlsStream<T> { | ||
fn remote_addr(&self) -> Option<SocketAddr> { | ||
let (inner, _) = self.get_ref(); | ||
inner.remote_addr() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.