diff --git a/letmeind/src/main.rs b/letmeind/src/main.rs index 7f020e8..8489e2c 100644 --- a/letmeind/src/main.rs +++ b/letmeind/src/main.rs @@ -223,7 +223,7 @@ async fn async_main(opts: Arc) -> ah::Result<()> { let conf = conf.read().await; let mut proto = Protocol::new(conn, &conf, &opts.rundir); if let Err(e) = proto.run().await { - eprintln!("Client '{}' ERROR: {}", proto.addr().ip(), e); + eprintln!("Client '{}' ERROR: {}", proto.peer_addr().ip(), e); } }); } diff --git a/letmeind/src/protocol.rs b/letmeind/src/protocol.rs index 76df5af..f34b938 100644 --- a/letmeind/src/protocol.rs +++ b/letmeind/src/protocol.rs @@ -52,8 +52,8 @@ impl<'a, C: ConnectionOps> Protocol<'a, C> { } } - pub fn addr(&self) -> SocketAddr { - self.conn.addr() + pub fn peer_addr(&self) -> SocketAddr { + self.conn.peer_addr() } async fn recv_msg(&mut self, expect_operation: Operation) -> ah::Result { @@ -223,7 +223,7 @@ impl<'a, C: ConnectionOps> Protocol<'a, C> { // Send an open-port request to letmeinfwd. assert_eq!(self.auth_state, AuthState::ChallengeResponseAuth); - if let Err(e) = fw.open_port(self.addr().ip(), port_type, *port).await { + if let Err(e) = fw.open_port(self.peer_addr().ip(), port_type, *port).await { let _ = self.send_go_away().await; return Err(err!("letmeinfwd firewall open: {e}")); } diff --git a/letmeind/src/server.rs b/letmeind/src/server.rs index 0c1bbce..d6677b5 100644 --- a/letmeind/src/server.rs +++ b/letmeind/src/server.rs @@ -14,25 +14,25 @@ use std::net::SocketAddr; use tokio::net::{TcpListener, TcpStream}; pub trait ConnectionOps { - fn addr(&self) -> SocketAddr; + fn peer_addr(&self) -> SocketAddr; async fn recv_msg(&mut self) -> ah::Result>; async fn send_msg(&mut self, msg: &Message) -> ah::Result<()>; } pub struct Connection { stream: TcpStream, - addr: SocketAddr, + peer_addr: SocketAddr, } impl Connection { - fn new(stream: TcpStream, addr: SocketAddr) -> ah::Result { - Ok(Self { stream, addr }) + fn new(stream: TcpStream, peer_addr: SocketAddr) -> ah::Result { + Ok(Self { stream, peer_addr }) } } impl ConnectionOps for Connection { - fn addr(&self) -> SocketAddr { - self.addr + fn peer_addr(&self) -> SocketAddr { + self.peer_addr } async fn recv_msg(&mut self) -> ah::Result> {