this post was submitted on 15 Nov 2024
6 points (87.5% liked)

Linux

8106 readers
106 users here now

Welcome to c/linux!

Welcome to our thriving Linux community! Whether you're a seasoned Linux enthusiast or just starting your journey, we're excited to have you here. Explore, learn, and collaborate with like-minded individuals who share a passion for open-source software and the endless possibilities it offers. Together, let's dive into the world of Linux and embrace the power of freedom, customization, and innovation. Enjoy your stay and feel free to join the vibrant discussions that await you!

Rules:

  1. Stay on topic: Posts and discussions should be related to Linux, open source software, and related technologies.

  2. Be respectful: Treat fellow community members with respect and courtesy.

  3. Quality over quantity: Share informative and thought-provoking content.

  4. No spam or self-promotion: Avoid excessive self-promotion or spamming.

  5. No NSFW adult content

  6. Follow general lemmy guidelines.

founded 1 year ago
MODERATORS
 

I am building a Wireguard tool for myself and I would like to receive events when a peer connects or disconnects. Does someone know if this is possible through some kernel API or EBPF?

you are viewing a single comment's thread
view the rest of the comments
[–] iii@mander.xyz 2 points 5 hours ago* (last edited 5 hours ago)

Thinking of the top if my head. I haven't tested this.

wg show lists connect peers, amongst other things. You can pipe that to grep to filter for just the peers.

With watch, you can periodically do the commands mentioned above, and execute another command on change.

With ntfy.sh you can easily get notifications on android or iphone.

The whole thing would look like.

watch --chgexit "wg show | grep peer" && curl -d "Someone (dis)connected!" ntfy.sh/mysecrettopic