20240721
This commit is contained in:
parent
17b03778ac
commit
5f1b118ff3
26 changed files with 164 additions and 160 deletions
25
.local/bin/mullvad_update
Executable file
25
.local/bin/mullvad_update
Executable file
|
@ -0,0 +1,25 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
{ read -r AN; read -r PRV; } < <(pass mullvad | sed -n '1p; s/^Privkey:\s*//p')
|
||||
|
||||
ADDRESS="$(curl 'https://api.mullvad.net/wg/' \
|
||||
-d "account=$AN" --data-urlencode "pubkey=$(wg pubkey <<< "$PRV")")"
|
||||
|
||||
j="$(curl 'https://api.mullvad.net/app/v1/relays/')"
|
||||
q='.wireguard.relays[] | "\(.hostname) \(.ipv4_addr_in) \(.public_key)"'
|
||||
|
||||
DNS="$(jq -r '.wireguard.ipv4_gateway' <<< "$j")"
|
||||
|
||||
while read -r file endpoint pubkey; do
|
||||
cat <<EOF > "$file.conf"
|
||||
[Interface]
|
||||
PrivateKey = $PRV
|
||||
Address = $ADDRESS
|
||||
DNS = $DNS
|
||||
|
||||
[Peer]
|
||||
PublicKey = $pubkey
|
||||
AllowedIPs = 0.0.0.0/0,::0/0
|
||||
Endpoint = $endpoint:51820
|
||||
EOF
|
||||
done < <(jq -r "$q" <<< "$j")
|
Loading…
Add table
Add a link
Reference in a new issue