Struct Peer

Source
pub struct Peer {
    pub public_key: [u8; 32],
    pub remove: Option<bool>,
    pub update_only: Option<bool>,
    pub preshared_key: Option<[u8; 32]>,
    pub endpoint: Option<SocketAddr>,
    pub persistent_keepalive_interval: Option<u16>,
    pub replace_allowed_ips: Option<bool>,
    pub allowed_ips: Vec<AllowedIp>,
}
Expand description

Documentation of each field comes from: https://www.wireguard.com/xplatform/#configuration-protocol

Fields§

§public_key: [u8; 32]

The value for this key should be a lowercase hex-encoded public key of a new peer entry, which this command adds. The same public key value may not repeat during a single message.

§remove: Option<bool>

This key/value combo is only valid in a set operation, in which case it indicates that the previously added peer entry should be removed from the interface.

§update_only: Option<bool>

This key/value combo is only valid in a set operation, in which case it causes the operation only occurs if the peer already exists as part of the interface.

§preshared_key: Option<[u8; 32]>

The value for this key should be a lowercase hex-encoded preshared-key of the previously added peer entry. The value may be an all zero string in the case of a set operation, in which case it indicates that the preshared-key should be removed.

§endpoint: Option<SocketAddr>

The value for this key is either IP:port for IPv4 or [IP]:port for IPv6, indicating the endpoint of the previously added peer entry.

§persistent_keepalive_interval: Option<u16>

The value for this is a decimal-string integer corresponding to the persistent keepalive interval of the previously added peer entry. The value 0 disables it.

§replace_allowed_ips: Option<bool>

This key/value combo is only valid in a set operation, in which case it indicates that the subsequent allowed IPs (perhaps an empty list) should replace any existing ones of the previously added peer entry, rather than append to the existing allowed IPs list.

§allowed_ips: Vec<AllowedIp>

The value for this is IP/cidr, indicating a new added allowed IP entry for the previously added peer entry. If an identical value already exists as part of a prior peer, the allowed IP entry will be removed from that peer and added to this peer.

Implementations§

Source§

impl Peer

Source

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

Source

pub fn remove(self, remove: bool) -> Self

Source

pub fn update_only(self, update_only: bool) -> Self

Source

pub fn preshared_key(self, preshared_key: [u8; 32]) -> Self

Source

pub fn endpoint(self, endpoint: SocketAddr) -> Self

Source

pub fn persistent_keepalive_interval( self, persistent_keepalive_interval: u16, ) -> Self

Source

pub fn replace_allowed_ips(self, replace_allowed_ips: bool) -> Self

Source

pub fn allowed_ips(self, allowed_ips: Vec<AllowedIp>) -> Self

Trait Implementations§

Source§

impl Clone for Peer

Source§

fn clone(&self) -> Peer

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Peer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Peer

Source§

fn default() -> Peer

Returns the “default value” for a type. Read more
Source§

impl Display for Peer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Peer

Source§

fn eq(&self, other: &Peer) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Peer

Source§

impl StructuralPartialEq for Peer

Auto Trait Implementations§

§

impl Freeze for Peer

§

impl RefUnwindSafe for Peer

§

impl Send for Peer

§

impl Sync for Peer

§

impl Unpin for Peer

§

impl UnwindSafe for Peer

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.