pub struct WGApi(/* private fields */);
Expand description

Shared multi-platform WireGuard management API

This struct adds an additional level of abstraction and can be used to detect the correct API implementation for most common platforms.

Implementations§

source§

impl WGApi

source

pub fn new( ifname: String, userspace: bool ) -> Result<Self, WireguardInterfaceError>

Create new instance of WGApi.

§Errors

Will return WireguardInterfaceError is platform is not supported.

Trait Implementations§

source§

impl WireguardInterfaceApi for WGApi

source§

fn create_interface(&self) -> Result<(), WireguardInterfaceError>

Creates a new WireGuard interface.
source§

fn assign_address( &self, address: &IpAddrMask ) -> Result<(), WireguardInterfaceError>

Assigns IP address to an existing interface.
source§

fn configure_peer_routing( &self, peers: &[Peer] ) -> Result<(), WireguardInterfaceError>

Add peer routing, basically a copy of wg-quick up <if_name> routing. Extracts all uniques allowed ips from Peer slice and add routing for every address.
source§

fn configure_interface( &self, config: &InterfaceConfiguration ) -> Result<(), WireguardInterfaceError>

Updates configuration of an existing WireGuard interface.
source§

fn remove_interface(&self) -> Result<(), WireguardInterfaceError>

Removes the WireGuard interface being managed. Read more
source§

fn configure_peer(&self, peer: &Peer) -> Result<(), WireguardInterfaceError>

Adds a peer or updates peer configuration.
source§

fn configure_dns(&self, dns: &[IpAddr]) -> Result<(), WireguardInterfaceError>

Sets the DNS configuration for the WireGuard interface. Read more
source§

fn remove_peer(&self, peer_pubkey: &Key) -> Result<(), WireguardInterfaceError>

Removes a configured peer with a given pubkey.
source§

fn read_interface_data(&self) -> Result<Host, WireguardInterfaceError>

Reads current WireGuard interface configuration and stats. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for WGApi

§

impl Send for WGApi

§

impl Sync for WGApi

§

impl Unpin for WGApi

§

impl !UnwindSafe for WGApi

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.