Rename 'remote_addr' to 'peer_address'.

This commit is contained in:
Sergio Benitez 2021-07-04 15:37:27 -07:00
parent b5e3569554
commit 76fab37e29
4 changed files with 8 additions and 8 deletions

View File

@ -32,8 +32,8 @@ pub trait Listener {
/// A 'Connection' represents an open connection to a client
pub trait Connection: AsyncRead + AsyncWrite {
/// The remote address, i.e. the client's socket address.
fn remote_addr(&self) -> Option<SocketAddr>;
/// The remote address, i.e. the client's socket address, if it is known.
fn peer_address(&self) -> Option<SocketAddr>;
}
pin_project_lite::pin_project! {
@ -184,7 +184,7 @@ impl Listener for TcpListener {
}
impl Connection for TcpStream {
fn remote_addr(&self) -> Option<SocketAddr> {
fn peer_address(&self) -> Option<SocketAddr> {
self.peer_addr().ok()
}
}

View File

@ -96,7 +96,7 @@ impl Listener for TlsListener {
}
impl Connection for TlsStream<TcpStream> {
fn remote_addr(&self) -> Option<SocketAddr> {
self.get_ref().0.remote_addr()
fn peer_address(&self) -> Option<SocketAddr> {
self.get_ref().0.peer_address()
}
}

View File

@ -296,8 +296,8 @@ impl<F: Future, I: AsyncWrite> AsyncWrite for CancellableIo<F, I> {
use crate::http::private::{Listener, Connection};
impl<F: Future, C: Connection> Connection for CancellableIo<F, C> {
fn remote_addr(&self) -> Option<std::net::SocketAddr> {
self.io.remote_addr()
fn peer_address(&self) -> Option<std::net::SocketAddr> {
self.io.peer_address()
}
}

View File

@ -443,7 +443,7 @@ impl Rocket<Orbit> {
let rocket = Arc::new(self);
let service_fn = move |conn: &CancellableIo<_, L::Connection>| {
let rocket = rocket.clone();
let remote = conn.remote_addr().unwrap_or_else(|| ([0, 0, 0, 0], 0).into());
let remote = conn.peer_address().unwrap_or_else(|| ([0, 0, 0, 0], 0).into());
async move {
Ok::<_, std::convert::Infallible>(hyper::service_fn(move |req| {
hyper_service_fn(rocket.clone(), remote, req)