pub struct Interface {Show 13 fields
pub address: Ipv4Net,
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: Ipv4NetInterface’s 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>Available on crate feature
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>
.add_peer(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§
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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