Skip to content

Instantly share code, notes, and snippets.

@j3lte
Forked from Dreyer/nordvpn.sh
Created February 8, 2023 12:16
Show Gist options
  • Save j3lte/97b4e6784d2463e2b073e3a61b74baf4 to your computer and use it in GitHub Desktop.
Save j3lte/97b4e6784d2463e2b073e3a61b74baf4 to your computer and use it in GitHub Desktop.

Revisions

  1. @Dreyer Dreyer renamed this gist Jan 20, 2017. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. @Dreyer Dreyer revised this gist Jan 5, 2017. 1 changed file with 0 additions and 20 deletions.
    20 changes: 0 additions & 20 deletions VPNAutoConnect.applescript
    Original file line number Diff line number Diff line change
    @@ -1,20 +0,0 @@
    #
    # Automatically reconnect when disconnected from the VPN.
    #
    # You don't need this if you're using the NordVPN application.
    # This is a utility for using native VPN connection settings on MacOS.
    #

    on idle
    tell application "System Events"
    tell current location of network preferences
    set myConnection to the service "WorkVPN"
    if myConnection is not null then
    if current configuration of myConnection is not connected then
    connect myConnection
    end if
    end if
    end tell
    return 120
    end tell
    end idle
  3. @Dreyer Dreyer renamed this gist Jan 5, 2017. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. @Dreyer Dreyer revised this gist Jan 5, 2017. 1 changed file with 20 additions and 0 deletions.
    20 changes: 20 additions & 0 deletions AutoConnectVPN.applescript
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    #
    # Automatically reconnect when disconnected from the VPN.
    #
    # You don't need this if you're using the NordVPN application.
    # This is a utility for using native VPN connection settings on MacOS.
    #

    on idle
    tell application "System Events"
    tell current location of network preferences
    set myConnection to the service "WorkVPN"
    if myConnection is not null then
    if current configuration of myConnection is not connected then
    connect myConnection
    end if
    end if
    end tell
    return 120
    end tell
    end idle
  5. @Dreyer Dreyer revised this gist Jan 5, 2017. No changes.
  6. @Dreyer Dreyer revised this gist Jan 5, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion vpn_status.sh
    Original file line number Diff line number Diff line change
    @@ -5,5 +5,5 @@ JSON=$(curl -s $URL)

    printf "\n"
    #echo $JSON | python -m json.tool
    echo $JSON | curl -s $URL | 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");'
    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"
  7. @Dreyer Dreyer created this gist Jan 5, 2017.
    9 changes: 9 additions & 0 deletions vpn_status.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    #!/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 | curl -s $URL | 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"