Struct wgctrl_rs::DeviceInfo[][src]

pub struct DeviceInfo {
    pub name: String,
    pub public_key: Option<Key>,
    pub private_key: Option<Key>,
    pub fwmark: Option<u32>,
    pub listen_port: Option<u16>,
    pub peers: Vec<PeerInfo>,
    // some fields omitted
}

Represents all available information about a WireGuard device (interface).

This struct contains the current configuration of the device and the current configuration and state of all of its peers. The peer statistics are retrieved once at construction time, and need to be updated manually by calling get_by_name.

Fields

The interface name of this device

The public encryption key of this interface (if present)

The private encryption key of this interface (if present)

The fwmark of this interface

The port to listen for incoming connections on

The list of all registered peers and their information

Methods

impl DeviceInfo
[src]

Enumerates all WireGuard interfaces currently present in the system and returns their names.

You can use get_by_name to retrieve more detailed information on each interface.

Example

for dev in DeviceInfo::enumerate()? {
    println!("{:#?}", DeviceInfo::get_by_name(&dev));
}

Loads all available information on a given interface (by name) from the kernel.

Actually doing this probably requires root privileges.

Example

for dev in DeviceInfo::enumerate()? {
    if let Ok(dev) = DeviceInfo::get_by_name(&dev) {
         println!(
            "Successfully loaded interface {}; public key: {:?}",
            dev.name, dev.public_key.map(|k| k.to_base64())
         )
    }
}

Trait Implementations

impl Debug for DeviceInfo
[src]

Formats the value using the given formatter. Read more

impl PartialEq for DeviceInfo
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Eq for DeviceInfo
[src]

impl Clone for DeviceInfo
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<'a> From<&'a wg_device> for DeviceInfo
[src]

Performs the conversion.

Auto Trait Implementations

impl Send for DeviceInfo

impl Sync for DeviceInfo