NM.WireGuardPeer¶
Fields¶
None
Methods¶
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Details¶
- class NM.WireGuardPeer¶
The settings of one WireGuard peer.
New in version 1.16.
- classmethod new()¶
- Returns:
a new, default, unsealed
NM.WireGuardPeer
instance.- Return type:
New in version 1.16.
- append_allowed_ip(allowed_ip, accept_invalid)¶
- Parameters:
- Returns:
True
if the value is a valid allowed-ips value,False
otherwise. Depending on accept_invalid, also invalid values are added.- Return type:
Appends allowed_ip setting to the list. This does not check for duplicates and always appends allowed_ip to the end of the list. If allowed_ip is valid, it will be normalized and a modified for might be appended. If allowed_ip is invalid, it will still be appended, but later verification will fail.
It is a bug trying to modify a sealed
NM.WireGuardPeer
instance.New in version 1.16.
- clear_allowed_ips()¶
Removes all allowed-ip entries.
It is a bug trying to modify a sealed
NM.WireGuardPeer
instance.New in version 1.16.
- cmp(b, compare_flags)¶
- Parameters:
b (
NM.WireGuardPeer
orNone
) – the otherNM.WireGuardPeer
to compare.compare_flags (
NM.SettingCompareFlags
) –NM.SettingCompareFlags
to affect the comparison.
- Returns:
zero of the two instances are equivalent or a non-zero integer otherwise. This defines a total ordering over the peers. Whether a peer is sealed or not, does not affect the comparison.
- Return type:
New in version 1.16.
- get_allowed_ip(idx, out_is_valid)¶
- Parameters:
idx (
int
) – the index from zero to (allowed-ips-len - 1) to retrieve.out_is_valid (
bool
orNone
) –True
if the returned value is a valid allowed-ip setting. This parameter is wrongly not marked as (out) argument, it is thus not accessible via introspection. This cannot be fixed without breaking API for introspection users.
- Returns:
the allowed-ip setting at index idx. If idx is out of range,
None
will be returned.- Return type:
New in version 1.16.
- get_allowed_ips_len()¶
- Returns:
the number of allowed-ips entries.
- Return type:
New in version 1.16.
- get_endpoint()¶
-
New in version 1.16.
- get_persistent_keepalive()¶
- Returns:
get the persistent-keepalive setting in seconds. Set to zero to disable keep-alive.
- Return type:
New in version 1.16.
- Returns:
get the secret flags for the preshared-key.
- Return type:
New in version 1.16.
- is_valid(check_non_secrets, check_secrets)¶
- Parameters:
- Raises:
- Returns:
True
if the peer is valid or fails with an error reason.- Return type:
New in version 1.16.
- new_clone(with_secrets)¶
- Parameters:
with_secrets (
bool
) – ifTrue
, the preshared-key secrets are copied as well. Otherwise, they will be removed.- Returns:
a clone of self. This instance is always unsealed.
- Return type:
New in version 1.16.
- ref()¶
- Returns:
returns the input argument self after incrementing the reference count.
Since 1.42, ref-counting of
NM.WireGuardPeer
is thread-safe.- Return type:
New in version 1.16.
- remove_allowed_ip(idx)¶
- Parameters:
idx (
int
) – the index from zero to (allowed-ips-len - 1) to retrieve. If the index is out of range,False
is returned and nothing is done.- Returns:
True
if idx was valid and the allowed-ip was removed.False
otherwise, and the peer will not be changed.- Return type:
Removes the allowed-ip at the given idx. This shifts all following entries one index down.
It is a bug trying to modify a sealed
NM.WireGuardPeer
instance.New in version 1.16.
- seal()¶
Seal the
NM.WireGuardPeer
instance. Afterwards, it is a bug to call all functions that modify the instance (except ref/unref). A sealed instance cannot be unsealed again, but you can create an unsealed copy withNM.WireGuardPeer.new_clone
().New in version 1.16.
- set_endpoint(endpoint, allow_invalid)¶
- Parameters:
- Returns:
True
if the endpoint isNone
or valid. For an invalid endpoint argument,False
is returned. Depending on allow_invalid, the instance will be modified.- Return type:
Sets or clears the endpoint of self.
It is a bug trying to modify a sealed
NM.WireGuardPeer
instance.New in version 1.16.
- set_persistent_keepalive(persistent_keepalive)¶
- Parameters:
persistent_keepalive (
int
) – the keep-alive value to set.
It is a bug trying to modify a sealed
NM.WireGuardPeer
instance.New in version 1.16.
- Parameters:
- Returns:
True
if the preshared-key is valid, otherwiseFalse
.None
is considered a valid value. If the key is invalid, it depends on accept_invalid whether the previous value was reset.- Return type:
Reset the preshared key. Note that if the preshared key is valid, it will be normalized (which may or may not modify the set value).
Note that the preshared-key is a secret and consequently has corresponding preshared-key-flags property. This is so that secrets can be optional and requested on demand from a secret-agent. Also, an invalid preshared-key may optionally cause
NM.WireGuardPeer.is_valid
() to fail or it may be accepted.It is a bug trying to modify a sealed
NM.WireGuardPeer
instance.New in version 1.16.
- Parameters:
preshared_key_flags (
NM.SettingSecretFlags
) – the secret flags to set.
It is a bug trying to modify a sealed
NM.WireGuardPeer
instance.New in version 1.16.
- set_public_key(public_key, accept_invalid)¶
- Parameters:
- Returns:
True
if the key was valid orNone
. ReturnsFalse
for invalid keys. Depending on accept_invalid will an invalid key be set or not.- Return type:
Reset the public key. Note that if the public key is valid, it will be normalized (which may or may not modify the set value).
It is a bug trying to modify a sealed
NM.WireGuardPeer
instance.New in version 1.16.
- unref()¶
Drop a reference to self. If the last reference is dropped, the instance is freed and all associate data released.
Since 1.42, ref-counting of
NM.WireGuardPeer
is thread-safe.New in version 1.16.