@@ -5,16 +5,43 @@ export LC_ALL=en_US.UTF-8
5
5
current_dir=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
6
6
source $current_dir /utils.sh
7
7
8
+
9
+
8
10
vpn_function () {
9
11
case $( uname -s) in
10
12
Linux)
13
+
14
+ verbose=$( get_tmux_option " @dracula-network-vpn-verbose" false)
15
+
11
16
# Show IP of tun0 if connected
12
17
vpn=$( ip -o -4 addr show dev tun0 | awk ' {print $4}' | cut -d/ -f1)
13
18
19
+ which -s tailscale > /dev/null
20
+ tailscale_installed=$?
21
+
14
22
if [[ $vpn =~ ^([0-9]{1,3}\. ){3}[0-9]{1,3}$ ]]; then
15
23
echo $vpn
24
+ elif [ $tailscale_installed ]; then
25
+ # if tailscale is installed
26
+ #
27
+ # https://www.reddit.com/r/Tailscale/comments/18dirro/is_there_a_way_i_can_tell_which_exit_node_i_am/
28
+ node=$( tailscale status --peers --json | jq ' .ExitNodeStatus' )
29
+ if [[ -z $node ]] || [[ " $node " == ' null' ]]; then
30
+ # no tailscale exit node, no output, since trafic isnt actually rerouted
31
+ echo " "
32
+ else
33
+ exitnode=$( tailscale status | grep " ; exit node" | awk ' {print $2}' )
34
+
35
+ if $verbose ; then
36
+ vpn_label=$( get_tmux_option " @dracula-network-vpn-label" " " )
37
+ echo " $vpn_label$exitnode "
38
+ else
39
+ vpn_label=$( get_tmux_option " @dracula-network-vpn-label" " Tailscale" )
40
+ echo " $vpn_label "
41
+ fi
42
+ fi
16
43
else
17
- echo " NO VPN "
44
+ echo " "
18
45
fi
19
46
;;
20
47
@@ -45,18 +72,22 @@ vpn_function() {
45
72
exitnode=$( tailscale status | grep " ; exit node" | cut -w -f 2)
46
73
47
74
if $verbose ; then
48
- echo " $exitnode "
75
+ vpn_label=$( get_tmux_option " @dracula-network-vpn-label" " " )
76
+ echo " $vpn_label$exitnode "
49
77
else
50
- echo " Tailscale"
78
+ vpn_label=$( get_tmux_option " @dracula-network-vpn-label" " Tailscale" )
79
+ echo " $vpn_label "
51
80
fi
52
81
fi
53
82
54
83
else
55
84
if $verbose ; then
56
85
vpn_name=$( echo $is_not_tailscale | sed " s/.*\" \(.*\)\" .*/\1/g" )
57
- echo " $vpn_name "
86
+ vpn_label=$( get_tmux_option " @dracula-network-vpn-label" " " )
87
+ echo " $vpn_label$vpn_name "
58
88
else
59
- echo " VPN"
89
+ vpn_label=$( get_tmux_option " @dracula-network-vpn-label" " VPN" )
90
+ echo " $vpn_label "
60
91
fi
61
92
fi
62
93
;;
0 commit comments