1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
use base64;
use std::fmt::{self, Display, Formatter};
use std::net::{IpAddr, SocketAddr};
#[derive(Clone, Debug, Default)]
pub struct PeerInfo {
pub pub_key: [u8; 32],
pub psk: Option<[u8; 32]>,
pub endpoint: Option<SocketAddr>,
pub allowed_ips: Vec<(IpAddr, u32)>,
pub keepalive: Option<u16>,
}
impl Display for PeerInfo {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
let encoded = base64::encode(&self.pub_key);
write!(f, "{}...{}", &encoded[..4], &encoded[encoded.len()-4..])
}
}
#[derive(Clone, Debug, Default)]
pub struct InterfaceInfo {
pub private_key: Option<[u8; 32]>,
pub pub_key: Option<[u8; 32]>,
pub listen_port: Option<u16>,
pub fwmark: Option<u32>,
}
|