pub struct Peer {
pub endpoint: Option<String>,
pub allowed_ips: Vec<IpNet>,
pub persistent_keepalive: u16,
pub key: Either<PrivateKey, PublicKey>,
pub preshared_key: Option<PresharedKey>,
}Expand description
Struct, that represents [Peer] section in configuration.
Fields§
§endpoint: Option<String>Peer’s endpoint.
allowed_ips: Vec<IpNet>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)
persistent_keepalive: u16Peer’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.
key: Either<PrivateKey, PublicKey>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.
Implementations§
Source§impl Peer
impl Peer
Sourcepub fn builder() -> PeerBuilder
pub fn builder() -> PeerBuilder
Create new PeerBuilder. Alias for PeerBuilder::new().
let interface = Peer::builder()
.allowed_ips([as_ipnet!("0.0.0.0/0")])
// <snip>
.build();Source§impl Peer
impl Peer
Sourcepub fn to_interface(
&self,
server_interface: &Interface,
options: ToInterfaceOptions,
) -> WireguardResult<Interface>
pub fn to_interface( &self, server_interface: &Interface, options: ToInterfaceOptions, ) -> WireguardResult<Interface>
Generate Interface from client’s Peer and server’s Interface.
options
§Errors
WireguardError::NoPrivateKeyProvided– peer don’t have private key. You need to providePrivateKeyfor creating interfaces from peers.WireguardError::NoAssignedIP– no assigned ip found. This means that your peer doesn’t have allowed ip, that is in interface’s addresses network.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Peer
impl<'de> Deserialize<'de> for Peer
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for Peer
Implements fmt::Display for exporting peer.
impl Display for Peer
Implements fmt::Display for exporting peer.
§Note
It exports only [Peer] ... part. To export full interface, use Peer::to_interface()
and then .to_string()
impl StructuralPartialEq for Peer
Auto Trait Implementations§
impl Freeze for Peer
impl RefUnwindSafe for Peer
impl Send for Peer
impl Sync for Peer
impl Unpin for Peer
impl UnwindSafe for Peer
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