pub struct InterfaceBuilder { /* private fields */ }Expand description
Builder, that used for creating Interfaces.
§Examples
use wireguard_conf::prelude::*;
let server_private_key = PrivateKey::random();
let interface = InterfaceBuilder::new()
.address("10.0.0.1/24".parse().unwrap())
.listen_port(6969)
.private_key(server_private_key.clone())
.set_dns(vec!["8.8.8.8".to_string(), "8.8.4.4".to_string()])
.endpoint("vpn.example.com".to_string())
// .add_peer(some_peer)
.build();
assert_eq!(interface.address, "10.0.0.1/24".parse().unwrap());
assert_eq!(interface.listen_port, Some(6969));
assert_eq!(interface.private_key, server_private_key);
assert_eq!(interface.dns, vec!["8.8.8.8", "8.8.4.4"]);
assert_eq!(interface.endpoint, Some("vpn.example.com".to_string()));Implementations§
Source§impl InterfaceBuilder
impl InterfaceBuilder
pub fn new() -> InterfaceBuilder
Sourcepub fn listen_port(self, listen_port: u16) -> Self
pub fn listen_port(self, listen_port: u16) -> Self
Set the listen port.
Sourcepub fn private_key(self, private_key: PrivateKey) -> Self
pub fn private_key(self, private_key: PrivateKey) -> Self
Set the private key.
Sourcepub fn endpoint(self, endpoint: String) -> Self
pub fn endpoint(self, endpoint: String) -> Self
Set the endpoint.
§Note
- In interface’s config this set
# Name = ... - If you export interface via [
Interface::as_peer()], exported peer will have thisPeer.endpoint
Sourcepub fn amnezia_settings(self, amnezia_settings: AmneziaSettings) -> Self
Available on crate feature amneziawg only.
pub fn amnezia_settings(self, amnezia_settings: AmneziaSettings) -> Self
amneziawg only.Sets AmneziaWG obfuscation values.
Trait Implementations§
Source§impl Default for InterfaceBuilder
impl Default for InterfaceBuilder
Source§fn default() -> InterfaceBuilder
fn default() -> InterfaceBuilder
Returns the “default value” for a type. Read more
Auto 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
Mutably borrows from an owned value. Read more
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