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>,
/* private fields */
}
Expand description
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§
§name: String
The interface name of this device
public_key: Option<Key>
The public encryption key of this interface (if present)
private_key: Option<Key>
The private encryption key of this interface (if present)
fwmark: Option<u32>
The fwmark of this interface
listen_port: Option<u16>
The port to listen for incoming connections on
peers: Vec<PeerInfo>
The list of all registered peers and their information
Implementations§
Source§impl DeviceInfo
impl DeviceInfo
Sourcepub fn enumerate() -> Result<Vec<String>, Error>
pub fn enumerate() -> Result<Vec<String>, Error>
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));
}
Sourcepub fn get_by_name(name: &str) -> Result<Self, Error>
pub fn get_by_name(name: &str) -> Result<Self, Error>
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§
Source§impl Clone for DeviceInfo
impl Clone for DeviceInfo
Source§fn clone(&self) -> DeviceInfo
fn clone(&self) -> DeviceInfo
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more