Commit Diff


commit - 83da8a758a6a97a51b74cd016ca688b55963a48f
commit + 17cccef34f22562a1f284e24a2cc3edfd8f94078
blob - /dev/null
blob + f44bc807d6b9b3fe6546da385bceaeba43ba557b (mode 644)
--- /dev/null
+++ wg-to-hostname
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+#
+# https://x61.ar
+#
+# Ex.: for i in $(ls *jp*.conf); do ./mullvad-to-hostname $i; done
+#
+
+## get info from mullvad's files
+DESC=$1
+ADDRESS=$(awk -F '[=,]' '/Address/{print $2}' "$1" | tr -d '[:space:]')
+PRIVATE_KEY=$(awk -F '[=,]' '/PrivateKey/{print $2}' "$1" | tr -d '[:space:]')
+PUBLIC_KEY=$(awk -F '[=,]' '/PublicKey/{print $2}' "$1" | tr -d '[:space:]')
+ENDPOINT_IP=$(awk -F '[=,:]' '/Endpoint/{print $2}' "$1" | tr -d '[:space:]')
+ENDPOINT_PORT=$(awk -F '[=,:]' '/Endpoint/{print $3}' "$1" | tr -d '[:space:]')
+
+## create the hostname.wg0 file
+cat <<EOF >>hostname.wg0_$1
+description ${DESC}
+inet ${ADDRESS}
+wgkey ${PRIVATE_KEY}=
+wgpeer ${PUBLIC_KEY}= wgrtable 1 wgendpoint ${ENDPOINT_IP} ${ENDPOINT_PORT} 0.0.0.0/0
+!route add default -link -iface wg0
+up
+EOF