hammerspoon icon indicating copy to clipboard operation
hammerspoon copied to clipboard

Feature request: VPN connection watcher

Open offbyone opened this issue 3 years ago • 2 comments

Caveat: I have no idea how to implement this.

I would like to be able to trigger events when my connected VPN changes, and ideally to be able to inspect the VPN configuration as well.

offbyone avatar Dec 26 '21 07:12 offbyone

@offbyone I haven't tried it, but it looks like most of the work is already done for you, have a look at http://www.hammerspoon.org/docs/hs.network.reachability.html

luckman212 avatar Dec 27 '21 01:12 luckman212

I've tried doing this using hs.network.reachability.forAddress, using a random 10.x.x.x host from within the target network, but in my case flags & hs.network.reachability.flags.reachable ends up always being non-zero, whether or not I'm on the VPN.

route get 10.x.x.x for that same IP shows it's using my default gateway when not connected to the VPN, so the IP is always going to be "reachable". I'm curious how others have configured their networks to get this reachability hook to work properly.

varju avatar Feb 03 '22 17:02 varju