pub struct Interface {Show 13 fields
pub address: Vec<IpNet>,
pub listen_port: Option<u16>,
pub private_key: PrivateKey,
pub dns: Vec<String>,
pub endpoint: Option<String>,
pub table: Option<Table>,
pub mtu: Option<usize>,
pub amnezia_settings: Option<AmneziaSettings>,
pub pre_up: Vec<String>,
pub pre_down: Vec<String>,
pub post_up: Vec<String>,
pub post_down: Vec<String>,
pub peers: Vec<Peer>,
}Expand description
Struct, that represents complete configuration (contains both [Interface] and [Peer]
sections).
Use InterfaceBuilder to create interface.
Fields§
§address: Vec<IpNet>Interface’s address.
/32 and /128 IP networks will be generated as regular ips (f.e. 1.2.3.4/32 -> 1.2.3.4)
You can also use InterfaceBuilder::add_network() to add a single network and
InterfaceBuilder::add_address() to add a single address.
listen_port: Option<u16>Port to listen for incoming VPN connections.
private_key: PrivateKeyNode’s private key.
dns: Vec<String>The DNS servers to announce to VPN clients via DHCP.
endpoint: Option<String>Endpoint.
[Interface]section will have# Name = <endpoint>comment at the top.- Exported
Peer(viaInterface::to_peer) will have this endpoint.
table: Option<Table>§mtu: Option<usize>Maximum Transmission Unit (MTU, aka packet/frame size) to use when connecting to the peer.
amnezia_settings: Option<AmneziaSettings>amneziawg only.AmneziaWG obfuscation values.
pre_up: Vec<String>Commands, that will be executed before the interface is brought up
pre_down: Vec<String>Commands, that will be executed before the interface is brought down
post_up: Vec<String>Commands, that will be executed after the interface is brought up
post_down: Vec<String>Commands, that will be executed after the interface is brought down
peers: Vec<Peer>Implementations§
Source§impl Interface
impl Interface
Sourcepub fn to_peer(&self) -> Peer
pub fn to_peer(&self) -> Peer
Get Peer from interface.
§Examples
// Create server node
let mut server = InterfaceBuilder::new()
// <snip>
.build();
// Create client node, and add server to client's peers
let client = InterfaceBuilder::new()
// <snip>
.peers([server.to_peer()]) // convert `Interface` to `Peer` using `.to_peer()` method.
.build();
// Add client to server's peers
server.peers.push(client.to_peer());
println!("Server config:\n{server}");
println!("Client config:\n{client}");Trait Implementations§
Source§impl<'de> Deserialize<'de> for Interface
impl<'de> Deserialize<'de> for Interface
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl StructuralPartialEq for Interface
Auto Trait Implementations§
impl Freeze for Interface
impl RefUnwindSafe for Interface
impl Send for Interface
impl Sync for Interface
impl Unpin for Interface
impl UnwindSafe for Interface
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more