diff --git a/src/mix_peer.rs b/src/mix_peer.rs index 8aab5dda73..053961718d 100644 --- a/src/mix_peer.rs +++ b/src/mix_peer.rs @@ -9,11 +9,12 @@ pub struct MixPeer { impl MixPeer { // note that very soon `next_hop_address` will be changed to `next_hop_metadata` pub fn new(next_hop_address: [u8; 32]) -> MixPeer { - let address = String::from_utf8_lossy(&next_hop_address) - .trim_end_matches(char::from(0)) - .to_string(); + let b = next_hop_address; + let host = Ipv4Addr::new(b[0], b[1], b[2], b[3]); + let port: u16 = u16::from_be_bytes([b[4], b[5]]); + let socket_address = SocketAddrV4::new(host, port); MixPeer { - connection: address, + connection: socket_address, } }