facebookincubator / wireguard_py

Cython library for Wireguard
MIT License
8 stars 4 forks source link

Add returned peer fields last_handshake_time, rx_bytes and tx_bytes #4

Closed cmoiccool closed 1 month ago

cmoiccool commented 1 month ago

Description

This pull request enhances the wireguard_py library by adding additional peer statistics and making necessary adjustments to support these new attributes. The most important changes include updating the Peer class to include new fields, modifying the list_peers function to display these new statistics, and adjusting the Cython interface to handle the new data.

Enhancements to peer statistics:

Adjustments to Cython interface:

Motivation and Context

The list_peers method was not returning the last_hanshake_time rx_bytes and tx_bytes returned by the kernel call making it impossible to use it to monitor peer status and statistics: Resolves #3

How Has This Been Tested?

Tests have been realised on an Ubuntu server with active peers on an existing interface with the modified wgpy.py to ensure that peers that have never connected and peers that has already connected have returned either values of 0 when never connected or valid values when already connected when the wgpy.py list-peers was called. I have also tested with a loop creating up to 40 peers to make sure that the list-peers returns all the created peers.

Screenshots (if appropriate):

Types of changes

Checklist:

facebook-github-bot commented 1 month ago

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot commented 1 month ago

This pull request has been merged in facebookincubator/wireguard_py@add244deaa133b34b879bed89c62ddce4884ecb5.