Skip to content

Instantly share code, notes, and snippets.

@varenc
Created December 24, 2024 19:05
Show Gist options
  • Save varenc/8e2eea60d82454baab2af88e56b373cc to your computer and use it in GitHub Desktop.
Save varenc/8e2eea60d82454baab2af88e56b373cc to your computer and use it in GitHub Desktop.
Fix nextdns archive.is domains with manual overrides, updating
function nextdns_fix_domains() {
function nextdns_existing_rules() { curl -sS 'https://api.nextdns.io/profiles/7dd729/rewrites' \
-H 'accept: */*' \
-H 'accept-language: en-US,en;q=0.9' \
-H "$(chromeCookies.py https://api.nextdns.io)"\
-H 'dnt: 1' \
-H 'origin: https://my.nextdns.io' \
-H 'priority: u=1, i' \
-H 'referer: https://my.nextdns.io/' \
-H 'sec-ch-ua: "Google Chrome";v="129", "Not=A?Brand";v="8", "Chromium";v="129"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "macOS"' \
-H 'sec-fetch-dest: empty' \
-H 'sec-fetch-mode: cors' \
-H 'sec-fetch-site: same-site' \
-H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36' | jq -r '.data[] | .id'
}
function nextdns_delete_rule() {
curl -sS 'https://api.nextdns.io/profiles/7dd729/rewrites/'"$1" \
-X 'DELETE' \
-H 'accept: */*' \
-H 'accept-language: en-US,en;q=0.9' \
-H "$(chromeCookies.py https://api.nextdns.io)"\
-H 'dnt: 1' \
-H 'origin: https://my.nextdns.io' \
-H 'priority: u=1, i' \
-H 'referer: https://my.nextdns.io/' \
-H 'sec-ch-ua: "Google Chrome";v="129", "Not=A?Brand";v="8", "Chromium";v="129"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "macOS"' \
-H 'sec-fetch-dest: empty' \
-H 'sec-fetch-mode: cors' \
-H 'sec-fetch-site: same-site' \
-H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36'
}
function nextdns_add_rule() {
[[ $# -eq 2 ]] || { echo "Usage: nextdns_add_rule name content"; return 1; }
echo2 "Adding rule '$1' -> '$2'";
curl 'https://api.nextdns.io/profiles/7dd729/rewrites' \
-H 'accept: */*' \
-H 'accept-language: en-US,en;q=0.9' \
-H 'content-type: application/json' \
-H "$(chromeCookies.py https://api.nextdns.io)"\
-H 'dnt: 1' \
-H 'origin: https://my.nextdns.io' \
-H 'priority: u=1, i' \
-H 'referer: https://my.nextdns.io/' \
-H 'sec-ch-ua: "Google Chrome";v="129", "Not=A?Brand";v="8", "Chromium";v="129"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "macOS"' \
-H 'sec-fetch-dest: empty' \
-H 'sec-fetch-mode: cors' \
-H 'sec-fetch-site: same-site' \
-H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36' \
--data-raw '{"name":"'"$1"'","content":"'"$2"'"}'
echo;
}
for r in $(nextdns_existing_rules); do
echo2 "Deleting rule $r"
nextdns_delete_rule $r
done
for d in archive.is archive.ph archive.vn archive.md archive.today archive.fo archive.li ; do
nextdns_add_rule $d "$(dig +short $d @8.8.8.8)" # <--- google DNS returns the correct IPs for archive.is domains
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment