Initial mullvad-speedtest implementation
This commit is contained in:
commit
2e446c9a48
3 changed files with 46 additions and 0 deletions
12
Dockerfile
Normal file
12
Dockerfile
Normal file
|
@ -0,0 +1,12 @@
|
|||
FROM librespeed-cli:latest
|
||||
|
||||
WORKDIR /tmp
|
||||
COPY setup.sh .
|
||||
RUN chmod +x setup.sh
|
||||
RUN ./setup.sh
|
||||
|
||||
COPY speedtest.sh /
|
||||
RUN chmod +x /speedtest.sh
|
||||
|
||||
ENTRYPOINT ["speedtest.sh"]
|
||||
|
10
setup.sh
Executable file
10
setup.sh
Executable file
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
# Download the Mullvad signing key
|
||||
sudo curl -fsSLo /usr/share/keyrings/mullvad-keyring.asc https://repository.mullvad.net/deb/mullvad-keyring.asc
|
||||
|
||||
# Add the Mullvad repository server to apt
|
||||
echo "deb [signed-by=/usr/share/keyrings/mullvad-keyring.asc arch=$( dpkg --print-architecture )] https://repository.mullvad.net/deb/stable $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/mullvad.list
|
||||
|
||||
# Install the package
|
||||
sudo apt update
|
||||
sudo apt install mullvad-vpn
|
24
speedtest.sh
Executable file
24
speedtest.sh
Executable file
|
@ -0,0 +1,24 @@
|
|||
#!/bin/bash
|
||||
|
||||
node_ids=$(mullvad relay list | grep -oE '[a-z]{2}-[a-z]{3}-\b(wg|ovpn)\b-[0-9]+')
|
||||
IFS=$'\n' read -r -d '' -a node_ids_arr <<< "$node_ids"
|
||||
|
||||
set -e pipefail
|
||||
|
||||
results='{}'
|
||||
for node in "${node_ids_arr[@]}"; do
|
||||
mullvad relay set location "$node" >/dev/null
|
||||
if ! mullvad connect --wait >/dev/null; then
|
||||
echo "$node->WARN: failed to connect, skipping" >&2
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "$node->INFO: connected to node"
|
||||
test_output=$(librespeed-cli --no-icmp --json | jq '.[0]')
|
||||
|
||||
echo "$node->INFO: ping: $(jq '.ping' <<< $test_output)ms, jitter: $(jq '.jitter' <<< $test_output)ms, download: $(jq '.download' <<< $test_output)mbps, upload: $(jq '.upload' <<< $test_output)mbps"
|
||||
results=$(jq --arg node "$node" --argjson test_output "$test_output" '. + {($node): $test_output}' <<< "$results")
|
||||
|
||||
mullvad disconnect --wait >/dev/null
|
||||
echo "$results" > /tmp/mullvad-speedtest-results.json
|
||||
done
|
Loading…
Add table
Reference in a new issue