pub fn write_peer_invitation(
    target_file: (&mut File, &str),
    network_name: &InterfaceName,
    peer: &Peer,
    server_peer: &Peer,
    root_cidr: &Cidr,
    keypair: KeyPair,
    server_api_addr: &SocketAddr,
) -> Result<(), Error> {
    let peer_invitation = InterfaceConfig {
        interface: InterfaceInfo {
            network_name: network_name.to_string(),
            private_key: keypair.private.to_base64(),
            address: IpNetwork::new(peer.ip, root_cidr.prefix())?,
            listen_port: None,
        },
        server: ServerInfo {
            external_endpoint: server_peer
                .endpoint
                .clone()
                .expect("The innernet server should have a WireGuard endpoint"),
            internal_endpoint: *server_api_addr,
            public_key: server_peer.public_key.clone(),
        },
    };

    peer_invitation.write_to(target_file.0, true, None)?;

    println!(
        "\nPeer \"{}\" added\n\
         Peer invitation file written to {}\n\
         Please send it to them securely (eg. via magic-wormhole) \
         to bootstrap them onto the network.",
        peer.name.bold(),
        target_file.1.bold()
    );

    Ok(())
}
/// Confirm and write a innernet invitation file after a peer has been created.
Confirm and write a innernet invitation file after a peer has been created.
Confirm and write a innernet invitation file after a peer has been created .
pub fn write_peer_invitation(
    target_file: (&mut File, &str),
    network_name: &InterfaceName,
    peer: &Peer,
    server_peer: &Peer,
    root_cidr: &Cidr,
    keypair: KeyPair,
    server_api_addr: &SocketAddr,
) -> Result<(), Error> {
    let peer_invitation = InterfaceConfig {
        interface: InterfaceInfo {
            network_name: network_name.to_string(),
            private_key: keypair.private.to_base64(),
            address: IpNetwork::new(peer.ip, root_cidr.prefix())?,
            listen_port: None,
        },
        server: ServerInfo {
            external_endpoint: server_peer
                .endpoint
                .clone()
                .expect("The innernet server should have a WireGuard endpoint"),
            internal_endpoint: *server_api_addr,
            public_key: server_peer.public_key.clone(),
        },
    };
    peer_invitation.write_to(target_file.0, true, None)?;
    println!(
        "\nPeer \"{}\" added\n\
         Peer invitation file written to {}\n\
         Please send it to them securely (eg. via magic-wormhole) \
         to bootstrap them onto the network.",
        peer.name.bold(),
        target_file.1.bold()
    );
    Ok(())
}
pub fn write_peer_invitation ( target_file : ( & mut File , & str ) , network_name : & InterfaceName , peer : & Peer , server_peer : & Peer , root_cidr : & Cidr , keypair : KeyPair , server_api_addr : & SocketAddr , ) -> Result < ( ) , Error > { let peer_invitation = InterfaceConfig { interface : InterfaceInfo { network_name : network_name . to_string ( ) , private_key : keypair . private . to_base64 ( ) , address : IpNetwork :: new ( peer . ip , root_cidr . prefix ( ) ) ? , listen_port : None , } , server : ServerInfo { external_endpoint : server_peer . endpoint . clone ( ) . expect ( " " ) , internal_endpoint : * server_api_addr , public_key : server_peer . public_key . clone ( ) , } , } ; peer_invitation . write_to ( target_file . 0 , true , None ) ? ; println ! ( " \n \" \" \n \
 \n \
 \
 " peer name bold ( ) target_file 1 bold ( ) ) ; Ok ( ( ) ) }
Confirm and write a innernet invitation file after a peer has been created.
Confirm and write a innernet invitation file after a peer has been created .
target_file
(&mut File, &str)
network_name
&InterfaceName
peer
&Peer
server_peer
&Peer
root_cidr
&Cidr
keypair
KeyPair
server_api_addr
&SocketAddr