Skip to content

Commit

Permalink
chore(hammerspoon): temporary ip link on NextDNS
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmoraes committed Mar 3, 2024
1 parent b0a24ca commit 1c15063
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .ejson/secrets.tmpl.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"_public_key": "6bf53a356a4b8abbc9a41ae2912787e56853e211653bb23d5da4a87ba6c9df6f",
"data": {
"global": {
"nextDNSLinkIPURL": "op://Personal/NextDNS/main/url"
},
"networks": {
"home": {
"fqdn": "op://Home/Wireless Router/FQDN",
Expand Down
19 changes: 18 additions & 1 deletion .shadow.d/.hammerspoon/tags/personal.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
-- pcall(require, "types.hammerspoon")

-- local logger = hs.logger.new("personal", "info")
local logger = hs.logger.new("personal", "verbose")

logger.i("loading personal tag settings")

local linkIPURL = os.getenv("NEXTDNS_LINK_IP_URL")

if linkIPURL == nil or linkIPURL:len() <= 0 then
logger.w("NEXTDNS_LINK_IP_URL unset or empty, skipping reachability callback")
else
hs.network.reachability.forAddress("172.24.174.4"):setCallback(function(self, flags)
if (flags & hs.network.reachability.flags.isLocalAddress) > 0 then
logger.i("VPN is up!")
hs.http.get(linkIPURL, nil)
else
logger.i("VPN is down!")
end
end):start()
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{{- /* cspell:disable */ -}}
NEXTDNS_LINK_IP_URL={{ .global.nextDNSLinkIPURL }}

0 comments on commit 1c15063

Please sign in to comment.