blob: e10e903911a62cec30476b2135e605b59d96dc91 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#!/bin/sh
# Mullvad Relay Test
location="Los Angeles"
# about 2 to 3 seconds for fast connection, 5 to 7 seconds for slow connection, to specified website
curl_maxtime=7
website=www.baidu.com
while getopts l:m:w: opt; do
case $opt in
l)location="$OPTARG";;
m)curl_maxtime="$OPTARG";;
w)website="$OPTARG";;
\?)exit 1;;
esac
done
mullvad relay update
# info gawk Node: Ranges, 7.1.3 Specifying Record Ranges with Patterns
# https://www.baeldung.com/linux/print-lines-between-two-patterns
# https://stackoverflow.com/q/39384283/9008720
for relay in $(mullvad relay list | awk -v location="$location" '
$0 ~ location {f=1;next}
/^\t[[:alpha:]]/ {f=0} f {
if($5 == "WireGuard,")
print $1
}'); do
mullvad relay set hostname "$relay"
while ! mullvad status | grep -q "Connected to $relay"; do
sleep 0.1;
done
curl -Ism"$curl_maxtime" "$website" && good_relays="$good_relays $relay"
done
echo "$good_relays" | tee "$XDG_DOCUMENTS_DIR/logs/mrt_$(printf "$location" | tr '[:upper:] ' '[:lower:]_')_$website.log"
|