Signed-off-by: Linus Wallgren <[email protected]>
---
I have never contributed to projects using `git-send-email` before, I
hope I didn't mess anything up :)
contrib/examples/reresolve-dns/reresolve-dns.sh | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/contrib/examples/reresolve-dns/reresolve-dns.sh
b/contrib/examples/reresolve-dns/reresolve-dns.sh
index 8ab3635..c844b22 100755
--- a/contrib/examples/reresolve-dns/reresolve-dns.sh
+++ b/contrib/examples/reresolve-dns/reresolve-dns.sh
@@ -10,8 +10,13 @@ export LC_ALL=C
CONFIG_FILE="$1"
[[ $CONFIG_FILE =~ ^[a-zA-Z0-9_=+.-]{1,15}$ ]] &&
CONFIG_FILE="/etc/wireguard/$CONFIG_FILE.conf"
-[[ $CONFIG_FILE =~ /?([a-zA-Z0-9_=+.-]{1,15})\.conf$ ]]
-INTERFACE="${BASH_REMATCH[1]}"
+
+if [[ $CONFIG_FILE == /etc/wireguard/* ]]; then
+ [[ $CONFIG_FILE =~ /?([a-zA-Z0-9_=+.-]{1,15})\.conf$ ]]
+ INTERFACE="${BASH_REMATCH[1]}"
+elif [[ $CONFIG_FILE =~ systemd ]]; then
+ INTERFACE=$(awk '/^Name=/ { print substr($0, 6) }' "$CONFIG_FILE")
+fi
process_peer() {
[[ $PEER_SECTION -ne 1 || -z $PUBLIC_KEY || -z $ENDPOINT ]] && return 0
@@ -34,6 +39,7 @@ while read -r line || [[ -n $line ]]; do
value="${stripped#*=}"; value="${value##*([[:space:]])}";
value="${value%%*([[:space:]])}"
[[ $key == "["* ]] && { process_peer; reset_peer_section; }
[[ $key == "[Peer]" ]] && PEER_SECTION=1
+ [[ $key == "[WireGuardPeer]" ]] && PEER_SECTION=1
if [[ $PEER_SECTION -eq 1 ]]; then
case "$key" in
PublicKey) PUBLIC_KEY="$value"; continue ;;
--
2.20.1
_______________________________________________
WireGuard mailing list
[email protected]
https://lists.zx2c4.com/mailman/listinfo/wireguard