maidsafe-archive / crust

Reliable p2p network connections in Rust with NAT traversal. One of the most needed libraries for any server-less / decentralised projects
BSD 3-Clause "New" or "Revised" License
956 stars 126 forks source link

Is there a method to obtain a peer port. (Q&A) #1152

Open bichovis opened 5 years ago

bichovis commented 5 years ago
pub fn print_connected_nodes(&self, service: &Service) {
    println!("Node count: {}", self.nodes.len());
    for (id, node) in &self.nodes {
        let ip = service.get_peer_ip_addr(node).unwrap();
        let status = if service.is_connected(node) {
            "Connected   "
        } else {
            "Disconnected"
        };

        println!("[{} - {}] {} {:?}", id, ip, status, node);
    }

    println!();
}

On the examples I've added the following line to obtain a peer IP let ip = sesion.get_peer_ip_addr(node).unwrap();

This method gives the IP but I can't find how to obtain the port. Is there any method that returns the peer port?

Thanks.