File tree 1 file changed +37
-4
lines changed
1 file changed +37
-4
lines changed Original file line number Diff line number Diff line change @@ -17,14 +17,47 @@ vpn_function() {
17
17
echo " NO VPN"
18
18
fi
19
19
;;
20
-
20
+
21
21
Darwin)
22
- vpn=$( scutil --nc list | grep Connected)
23
22
24
- if [ -z $vpn ]; then
23
+ verbose=$( get_tmux_option " @dracula-network-vpn-verbose" false)
24
+
25
+ vpn=" $( scutil --nc list | sed " s/\*//g" | grep Connected) "
26
+
27
+ is_not_tailscale=$( echo " $vpn " | grep -v Tailscale)
28
+
29
+ which -s tailscale > /dev/null
30
+ tailscale_installed=$?
31
+
32
+ if [ -z " $vpn " ]; then
25
33
echo " "
34
+
35
+ elif [ $tailscale_installed ] && [ -z " $is_not_tailscale " ]; then
36
+ # if tailscale is installed and no other vpn is connected. this is because tailscale will
37
+ # always show as connected for some reason.
38
+ #
39
+ # https://www.reddit.com/r/Tailscale/comments/18dirro/is_there_a_way_i_can_tell_which_exit_node_i_am/
40
+ node=$( tailscale status --peers --json | jq ' .ExitNodeStatus' )
41
+ if [[ -z $node ]] || [[ " $node " == ' null' ]]; then
42
+ # no tailscale exit node, no output, since trafic isnt actually rerouted
43
+ echo " "
44
+ else
45
+ exitnode=$( tailscale status | grep " ; exit node" | cut -w -f 2)
46
+
47
+ if $verbose ; then
48
+ echo " $exitnode "
49
+ else
50
+ echo " Tailscale"
51
+ fi
52
+ fi
53
+
26
54
else
27
- echo " VPN"
55
+ if $verbose ; then
56
+ vpn_name=$( echo $is_not_tailscale | sed " s/.*\" \(.*\)\" .*/\1/g" )
57
+ echo " $vpn_name "
58
+ else
59
+ echo " VPN"
60
+ fi
28
61
fi
29
62
;;
30
63
You can’t perform that action at this time.
0 commit comments