pub struct WireGuardPeer {Show 16 fields
pub public_key: [u8; 32],
pub preshared_key: [u8; 32],
pub endpoint: Option<SocketAddr>,
pub allowed_ips: Vec<AllowedIp>,
pub handshake_state: HandshakeState,
pub handshake: HandshakeContext,
pub session: Option<SessionKeys>,
pub replay_window: AntiReplayWindow,
pub last_handshake: u64,
pub last_received: u64,
pub last_sent: u64,
pub keepalive_interval: u64,
pub handshake_retries: u32,
pub next_retry_ms: u64,
pub tx_bytes: u64,
pub rx_bytes: u64,
}Expand description
WireGuard peer
Fields§
§public_key: [u8; 32]Peer’s static public key
Pre-shared key (optional, all zeros if none)
endpoint: Option<SocketAddr>Peer’s endpoint (IP:port)
allowed_ips: Vec<AllowedIp>Allowed IP ranges
handshake_state: HandshakeStateHandshake state
handshake: HandshakeContextCurrent handshake context
session: Option<SessionKeys>Current session keys
replay_window: AntiReplayWindowAnti-replay window
last_handshake: u64Last handshake timestamp (uptime seconds)
last_received: u64Last data received timestamp
last_sent: u64Last data sent timestamp
keepalive_interval: u64Persistent keepalive interval (0 = disabled)
handshake_retries: u32Handshake retry count
next_retry_ms: u64Next retry time (uptime milliseconds)
tx_bytes: u64Bytes transmitted
rx_bytes: u64Bytes received
Implementations§
Source§impl WireGuardPeer
impl WireGuardPeer
Set pre-shared key
Sourcepub fn add_allowed_ip(&mut self, ip: AllowedIp)
pub fn add_allowed_ip(&mut self, ip: AllowedIp)
Add an allowed IP range
Sourcepub fn is_allowed(&self, ip: &Ipv4Address) -> bool
pub fn is_allowed(&self, ip: &Ipv4Address) -> bool
Check if a destination IP is allowed for this peer
Sourcepub fn is_session_expired(&self, now: u64) -> bool
pub fn is_session_expired(&self, now: u64) -> bool
Check if session has expired
Sourcepub fn needs_keepalive(&self, now: u64) -> bool
pub fn needs_keepalive(&self, now: u64) -> bool
Check if keepalive should be sent
Sourcepub fn retry_delay_ms(&self) -> u64
pub fn retry_delay_ms(&self) -> u64
Calculate next handshake retry delay with exponential backoff (ms)