pub struct PeerBuilder { /* private fields */ }Expand description
Builder for Peer.
Implementations§
Source§impl PeerBuilder
impl PeerBuilder
Sourcepub fn allowed_ips<VALUE: Into<Vec<IpNet>>>(
&mut self,
value: VALUE,
) -> &mut Self
pub fn allowed_ips<VALUE: Into<Vec<IpNet>>>( &mut self, value: VALUE, ) -> &mut Self
Peer’s allowed IPs.
- */32 and */128 ipnets will be generated as regular ips (f.e. 1.2.3.4/32 -> 1.2.3.4)
Sourcepub fn persistent_keepalive(&mut self, value: u16) -> &mut Self
pub fn persistent_keepalive(&mut self, value: u16) -> &mut Self
Peer’s persistent keepalive.
Represents in seconds how often to send an authenticated empty packet to the peer, for the purpose of keeping a stateful firewall or NAT mapping valid persistently.
Setting this value to 0 omits it in config.
Sourcepub fn key(&mut self, value: Either<PrivateKey, PublicKey>) -> &mut Self
pub fn key(&mut self, value: Either<PrivateKey, PublicKey>) -> &mut Self
Peer’s key.
If PrivateKey is provided, then peer can be exported to interface & full config.
Otherwise only to peer section of config.
Peer’s preshared-key.
Source§impl PeerBuilder
impl PeerBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create new PeerBuilder.
let interface = PeerBuilder::new()
.allowed_ips([as_ipnet!("0.0.0.0/0")])
// <snip>
.build();Sourcepub fn private_key(&mut self, value: PrivateKey) -> &mut Self
pub fn private_key(&mut self, value: PrivateKey) -> &mut Self
Sets private key.
Shorthand for .key(Either::Left(value)).
Sourcepub fn public_key(&mut self, value: PublicKey) -> &mut Self
pub fn public_key(&mut self, value: PublicKey) -> &mut Self
Sets public key.
Shorthand for .key(Either::Right(value)).
Trait Implementations§
Source§impl Clone for PeerBuilder
impl Clone for PeerBuilder
Source§fn clone(&self) -> PeerBuilder
fn clone(&self) -> PeerBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for PeerBuilder
impl RefUnwindSafe for PeerBuilder
impl Send for PeerBuilder
impl Sync for PeerBuilder
impl Unpin for PeerBuilder
impl UnwindSafe for PeerBuilder
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