hammerspoon
hammerspoon copied to clipboard
Feature request: VPN connection watcher
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 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
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.