pub struct InterfaceBuilder { /* private fields */ }Expand description
Builder for Interface.
Implementations§
Source§impl InterfaceBuilder
impl InterfaceBuilder
Sourcepub fn address<VALUE: Into<Vec<IpNet>>>(&mut self, value: VALUE) -> &mut Self
pub fn address<VALUE: Into<Vec<IpNet>>>(&mut self, value: VALUE) -> &mut Self
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.
Sourcepub fn listen_port(&mut self, value: u16) -> &mut Self
pub fn listen_port(&mut self, value: u16) -> &mut Self
Port to listen for incoming VPN connections.
Sourcepub fn private_key(&mut self, value: PrivateKey) -> &mut Self
pub fn private_key(&mut self, value: PrivateKey) -> &mut Self
Node’s private key.
Sourcepub fn dns<VALUE: Into<Vec<String>>>(&mut self, value: VALUE) -> &mut Self
pub fn dns<VALUE: Into<Vec<String>>>(&mut self, value: VALUE) -> &mut Self
The DNS servers to announce to VPN clients via DHCP.
Sourcepub fn endpoint<VALUE: Into<String>>(&mut self, value: VALUE) -> &mut Self
pub fn endpoint<VALUE: Into<String>>(&mut self, value: VALUE) -> &mut Self
Endpoint.
[Interface]section will have# Name = <endpoint>comment at the top.- Exported
Peer(viaInterface::to_peer) will have this endpoint.
Sourcepub fn mtu(&mut self, value: usize) -> &mut Self
pub fn mtu(&mut self, value: usize) -> &mut Self
Maximum Transmission Unit (MTU, aka packet/frame size) to use when connecting to the peer.
Sourcepub fn amnezia_settings(&mut self, value: AmneziaSettings) -> &mut Self
Available on crate feature amneziawg only.
pub fn amnezia_settings(&mut self, value: AmneziaSettings) -> &mut Self
amneziawg only.AmneziaWG obfuscation values.
Sourcepub fn pre_up<VALUE: Into<Vec<String>>>(&mut self, value: VALUE) -> &mut Self
pub fn pre_up<VALUE: Into<Vec<String>>>(&mut self, value: VALUE) -> &mut Self
Commands, that will be executed before the interface is brought up
Sourcepub fn pre_down<VALUE: Into<Vec<String>>>(&mut self, value: VALUE) -> &mut Self
pub fn pre_down<VALUE: Into<Vec<String>>>(&mut self, value: VALUE) -> &mut Self
Commands, that will be executed before the interface is brought down
Sourcepub fn post_up<VALUE: Into<Vec<String>>>(&mut self, value: VALUE) -> &mut Self
pub fn post_up<VALUE: Into<Vec<String>>>(&mut self, value: VALUE) -> &mut Self
Commands, that will be executed after the interface is brought up
Sourcepub fn post_down<VALUE: Into<Vec<String>>>(&mut self, value: VALUE) -> &mut Self
pub fn post_down<VALUE: Into<Vec<String>>>(&mut self, value: VALUE) -> &mut Self
Commands, that will be executed after the interface is brought down
Source§impl InterfaceBuilder
impl InterfaceBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create new InterfaceBuilder.
let interface = InterfaceBuilder::new()
.address([as_ipnet!("10.0.0.1/24")])
// <snip>
.build();Sourcepub fn add_network<T: Into<IpNet>>(&mut self, value: T) -> &mut Self
pub fn add_network<T: Into<IpNet>>(&mut self, value: T) -> &mut Self
Adds IP Network to Address = ... field.
value is Into<IpNet>, which means that it can be either ipnet::IpNet or std::net::IpAddr.
§Example
use wireguard_conf::{as_ipnet, prelude::*};
let interface = InterfaceBuilder::new()
.add_network(as_ipnet!("1.2.3.4/16"))
.add_network(as_ipnet!("fd00:DEAD:BEEF::1/48"))
.build();
assert_eq!(
interface.address,
vec![
as_ipnet!("1.2.3.4/16"),
as_ipnet!("fd00:DEAD:BEEF::1/48")
]
);Sourcepub fn add_address<T: Into<IpAddr>>(&mut self, value: T) -> &mut Self
pub fn add_address<T: Into<IpAddr>>(&mut self, value: T) -> &mut Self
Adds IP address to Address = ... field.
value is Into<IpAddr>, which means that it can be either std::net::Ipv4Addr or std::net::Ipv6Addr.
§Example
use wireguard_conf::{as_ipaddr, as_ipnet, prelude::*};
let interface = InterfaceBuilder::new()
.add_address(as_ipaddr!("1.2.3.4"))
.add_address(as_ipaddr!("fd00::1"))
.build();
// /32 and /128 are added automatically
assert_eq!(
interface.address,
vec![
as_ipnet!("1.2.3.4/32"),
as_ipnet!("fd00::1/128"),
]
);Trait Implementations§
Source§impl Clone for InterfaceBuilder
impl Clone for InterfaceBuilder
Source§fn clone(&self) -> InterfaceBuilder
fn clone(&self) -> InterfaceBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for InterfaceBuilder
impl RefUnwindSafe for InterfaceBuilder
impl Send for InterfaceBuilder
impl Sync for InterfaceBuilder
impl Unpin for InterfaceBuilder
impl UnwindSafe for InterfaceBuilder
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