Last active
February 3, 2024 21:55
-
-
Save Dreyer/161b920f0d8300ed3bc750ae2f80c339 to your computer and use it in GitHub Desktop.
Check the status of a NordVPN connection from your shell.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
URL='https://nordvpn.com/wp-admin/admin-ajax.php?action=get_user_info_data' | |
JSON=$(curl -s $URL) | |
printf "\n" | |
#echo $JSON | python -m json.tool | |
echo $JSON | python -c 'import sys, json; data = json.load(sys.stdin); print "IP: %s (%s)\nStatus: %s" % (data["ip"], data["isp"], "\033[32mProtected" if data["status"] is True else "\033[31mUnprotected");' | |
printf "\n" |
the URL='https://api.nordvpn.com/vpn/check/full' is less accurate than the last url https://nordvpn.com/wp-admin/admin-ajax.php?action=get_user_info_data
thanks for sharing
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
They changed their code. The address you used does not always work. This fixes it
#!/bin/bash
URL='https://api.nordvpn.com/vpn/check/full'
JSON=$(curl -s $URL)
printf "\n"
#echo $JSON | python -m json.tool
echo $JSON | python -c 'import sys, json; data = json.load(sys.stdin); print "IP: %s (%s)\nStatus: %s" % (data["ip"], data["isp"], "\033[32mProtected" if data["status"] == "Protected" else "\033[31mUnprotected");'
printf "\n"