Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle situation where wireguard netlink returns invalid data #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jiri-lunacek
Copy link

We occasionally encounter that wg interface returns invalid data.
Either returns NULL in last handshake or returns a peer twice.

This short patch handles these situations.

skip duplicate key rather than raise assertion
@@ -27,7 +27,10 @@ def __init__(self, peer, spill_preshared_keys=False):
self.endpoint = peer.get_attr('WGPEER_A_ENDPOINT')
self.persistent_keepalive_interval = peer.get_attr('WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL')
self.last_handshake_time = peer.get_attr('WGPEER_A_LAST_HANDSHAKE_TIME')
if not self.last_handshake_time > 0:
try:
if not self.last_handshake_time > 0:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of a try+except, you could also check if whether the variable has a None value:

if self.last_handshake_time is None or not self.last_handshake_time > 0:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants