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?

  • iii@mander.xyz
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    3 days 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