Struct wireguard_control::DeviceUpdate [−][src]
pub struct DeviceUpdate { /* fields omitted */ }
Expand description
Builds and represents a configuration that can be applied to a WireGuard interface.
This is the primary way of changing the settings of an interface.
Note that if an interface exists, the configuration is applied on top of the existing settings, and missing parts are not overwritten or set to defaults.
If this is not what you want, use delete_interface
to remove the interface entirely before applying the new configuration.
Example
let our_keypair = KeyPair::generate();
let peer_keypair = KeyPair::generate();
let server_addr = "192.168.1.1:51820".parse()?;
DeviceUpdate::new()
.set_keypair(our_keypair)
.replace_peers()
.add_peer_with(&peer_keypair.public, |peer| {
peer.set_endpoint(server_addr)
.replace_allowed_ips()
.allow_all_ips()
}).apply(&"wg-example".parse().unwrap(), Backend::Userspace);
println!("Send these keys to your peer: {:#?}", peer_keypair);
Implementations
Sets a new keypair to be applied to the interface.
This is a convenience method that simply wraps
set_public_key
and set_private_key
.
Specifies a new public key to be applied to the interface.
Specifies that the public key for this interface should be unset.
Sets a new private key to be applied to the interface.
Specifies that the private key for this interface should be unset.
Specifies the fwmark value that should be applied to packets coming from the interface.
Specifies that fwmark should not be set on packets from the interface.
Specifies the port to listen for incoming packets on.
This is useful for a server configuration that listens on a fixed endpoint.
Specifies that a random port should be used for incoming packets.
This is probably what you want in client configurations.
Specifies a new peer configuration to be added to the interface.
See PeerConfigBuilder
for details on building
peer configurations. This method can be called more than once, and all
peers will be added to the configuration.
pub fn add_peer_with(
self,
pubkey: &Key,
builder: impl Fn(PeerConfigBuilder) -> PeerConfigBuilder
) -> Self
pub fn add_peer_with(
self,
pubkey: &Key,
builder: impl Fn(PeerConfigBuilder) -> PeerConfigBuilder
) -> Self
Specifies a new peer configuration using a builder function.
This is simply a convenience method to make adding peers more fluent. This method can be called more than once, and all peers will be added to the configuration.
Specifies multiple peer configurations to be added to the interface.
Specifies that the peer configurations in this DeviceConfigBuilder
should
replace the existing configurations on the interface, not modify or append to them.
Specifies that the peer with this public key should be removed from the interface.
Trait Implementations
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Auto Trait Implementations
impl RefUnwindSafe for DeviceUpdate
impl Send for DeviceUpdate
impl Sync for DeviceUpdate
impl Unpin for DeviceUpdate
impl UnwindSafe for DeviceUpdate
Blanket Implementations
Mutably borrows from an owned value. Read more