From e7fd105d4727cf873ff5c81631999e6fcd1ea276 Mon Sep 17 00:00:00 2001 From: sanj <67624670+iodrift@users.noreply.github.com> Date: Tue, 30 Jul 2024 17:48:00 -0700 Subject: [PATCH] Auto-update: Tue Jul 30 17:48:00 PDT 2024 --- vpn | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 vpn diff --git a/vpn b/vpn new file mode 100755 index 0000000..a31721e --- /dev/null +++ b/vpn @@ -0,0 +1,29 @@ +#!/bin/bash + +# Get the suggested exit node +exit_node=$(tailscale exit-node suggest | awk -F': ' '/Suggested exit node/ {print substr($2, 1, length($2)-1)}') + +# Print the exit node +echo "Suggested exit node: $exit_node" + +# Set the exit node +tailscale set --exit-node=$exit_node + +# Verify the exit node +exit_node_info=$(curl -s https://am.i.mullvad.net/json) + +# Parse the JSON response to get the hostname +exit_node_hostname=$(echo $exit_node_info | jq -r '.mullvad_exit_ip_hostname') + +echo "Current exit node hostname: $exit_node_hostname" + +# Get the part before the first '.' in the exit_node +exit_node_short=$(echo $exit_node | cut -d'.' -f1) + +# Verify that the exit_node_short and exit_node_hostname are equal +if [ "$exit_node_short" == "$exit_node_hostname" ]; then + echo "Exit node set successfully!" +else + echo "Failed to set exit node!" +fi +