5405: mastersrv: Small convenience function r=def- a=heinrich5991

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: heinrich5991 <heinrich5991@gmail.com>
This commit is contained in:
bors[bot] 2022-06-13 22:30:35 +00:00 committed by GitHub
commit bbc447a995
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View file

@ -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 { impl fmt::Display for Addr {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut buf: ArrayString<[u8; 128]> = ArrayString::new(); let mut buf: ArrayString<[u8; 128]> = ArrayString::new();
write!( write!(&mut buf, "{}://{}", self.protocol, self.to_socket_addr()).unwrap();
&mut buf,
"{}://{}",
self.protocol,
SocketAddr::new(self.ip, self.port)
)
.unwrap();
buf.fmt(f) buf.fmt(f)
} }
} }

View file

@ -763,7 +763,7 @@ fn handle_register(
tokio::spawn(send_challenge( tokio::spawn(send_challenge(
connless_request_token_7, connless_request_token_7,
shared.socket.clone(), shared.socket.clone(),
SocketAddr::new(addr.ip, addr.port), addr.to_socket_addr(),
register.challenge_secret, register.challenge_secret,
challenge.current, challenge.current,
)); ));