pub struct Adapter { /* private fields */ }
Expand description
Representation of a wireGuard adapter with safe idiomatic bindings to the functionality provided by the WireGuard* C functions.
The Adapter::create
and Adapter::open
functions serve as the entry point to using
wireguard functionality
Wrapper around a WIREGUARD_ADAPTER_HANDLE
Related functions from WireGuardXXX are functions with an adapter self parameter
Implementations§
Source§impl Adapter
impl Adapter
Sourcepub fn create(
wireguard: &Wireguard,
pool: &str,
name: &str,
guid: Option<u128>,
) -> Result<Adapter>
pub fn create( wireguard: &Wireguard, pool: &str, name: &str, guid: Option<u128>, ) -> Result<Adapter>
Creates a new wireguard adapter inside the pool pool
with name name
Optionally a GUID can be specified that will become the GUID of this adapter once created.
Sourcepub fn open(wireguard: &Wireguard, name: &str) -> Result<Adapter>
pub fn open(wireguard: &Wireguard, name: &str) -> Result<Adapter>
Attempts to open an existing wireguard with name name
.
Sourcepub fn set_config(&self, config: &SetInterface) -> Result<()>
pub fn set_config(&self, config: &SetInterface) -> Result<()>
Sets the wireguard configuration of this adapter
Sourcepub fn set_default_route(
&self,
interface_addrs: &[IpNet],
config: &SetInterface,
) -> Result<()>
pub fn set_default_route( &self, interface_addrs: &[IpNet], config: &SetInterface, ) -> Result<()>
Assigns this adapter an ip address and adds route(s) so that packets sent
within the interface_addr
ipnet will be sent across the WireGuard VPN
Sourcepub fn set_route_with_metric(
&self,
interface_addrs: &[IpNet],
config: &SetInterface,
metric: u32,
) -> Result<()>
pub fn set_route_with_metric( &self, interface_addrs: &[IpNet], config: &SetInterface, metric: u32, ) -> Result<()>
Assigns this adapter an ip address and adds route(s) so that packets sent
within the interface_addr
ipnet will be sent across the WireGuard VPN
if no route with lower metric (higher priority) is found
Sourcepub fn get_luid(&self) -> u64
pub fn get_luid(&self) -> u64
Returns the adapter’s LUID. This is a 64bit unique identifier that windows uses when referencing this adapter
Sourcepub fn set_logging(&self, level: AdapterLoggingLevel) -> bool
pub fn set_logging(&self, level: AdapterLoggingLevel) -> bool
Sets the logging level of this adapter
Log messages will be sent to the current logger (set using crate::set_logger
Sourcepub fn get_config(&self) -> WireguardInterface
pub fn get_config(&self) -> WireguardInterface
Gets the current configuration of this adapter