⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

WireGuardPeer

Struct WireGuardPeer 

Source
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

§preshared_key: [u8; 32]

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: HandshakeState

Handshake state

§handshake: HandshakeContext

Current handshake context

§session: Option<SessionKeys>

Current session keys

§replay_window: AntiReplayWindow

Anti-replay window

§last_handshake: u64

Last handshake timestamp (uptime seconds)

§last_received: u64

Last data received timestamp

§last_sent: u64

Last data sent timestamp

§keepalive_interval: u64

Persistent keepalive interval (0 = disabled)

§handshake_retries: u32

Handshake retry count

§next_retry_ms: u64

Next retry time (uptime milliseconds)

§tx_bytes: u64

Bytes transmitted

§rx_bytes: u64

Bytes received

Implementations§

Source§

impl WireGuardPeer

Source

pub fn new(public_key: [u8; 32]) -> Self

Create a new peer

Source

pub fn set_preshared_key(&mut self, psk: [u8; 32])

Set pre-shared key

Source

pub fn add_allowed_ip(&mut self, ip: AllowedIp)

Add an allowed IP range

Source

pub fn is_allowed(&self, ip: &Ipv4Address) -> bool

Check if a destination IP is allowed for this peer

Source

pub fn is_session_expired(&self, now: u64) -> bool

Check if session has expired

Source

pub fn needs_keepalive(&self, now: u64) -> bool

Check if keepalive should be sent

Source

pub fn retry_delay_ms(&self) -> u64

Calculate next handshake retry delay with exponential backoff (ms)

Auto Trait Implementations§

§

impl !Freeze for WireGuardPeer

§

impl RefUnwindSafe for WireGuardPeer

§

impl Send for WireGuardPeer

§

impl Sync for WireGuardPeer

§

impl Unpin for WireGuardPeer

§

impl UnwindSafe for WireGuardPeer

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.