From 135577b7f63aa11927f7eb98547f1f3a59597c72 Mon Sep 17 00:00:00 2001 From: heinrich5991 Date: Mon, 13 Jun 2022 17:00:54 +0200 Subject: [PATCH] mastersrv: Small convenience function --- src/mastersrv/src/addr.rs | 14 +++++++------- src/mastersrv/src/main.rs | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/mastersrv/src/addr.rs b/src/mastersrv/src/addr.rs index dad5128ee..b6abaad9a 100644 --- a/src/mastersrv/src/addr.rs +++ b/src/mastersrv/src/addr.rs @@ -101,16 +101,16 @@ impl Protocol { } } +impl Addr { + pub fn to_socket_addr(self) -> SocketAddr { + SocketAddr::new(self.ip, self.port) + } +} + impl fmt::Display for Addr { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let mut buf: ArrayString<[u8; 128]> = ArrayString::new(); - write!( - &mut buf, - "{}://{}", - self.protocol, - SocketAddr::new(self.ip, self.port) - ) - .unwrap(); + write!(&mut buf, "{}://{}", self.protocol, self.to_socket_addr()).unwrap(); buf.fmt(f) } } diff --git a/src/mastersrv/src/main.rs b/src/mastersrv/src/main.rs index 985ad0706..1c03f6a1b 100644 --- a/src/mastersrv/src/main.rs +++ b/src/mastersrv/src/main.rs @@ -763,7 +763,7 @@ fn handle_register( tokio::spawn(send_challenge( connless_request_token_7, shared.socket.clone(), - SocketAddr::new(addr.ip, addr.port), + addr.to_socket_addr(), register.challenge_secret, challenge.current, ));