* [PATCH] reresolve-dns: Add systemd-networkd support
@ 2019-12-21 13:22 Linus Wallgren
0 siblings, 0 replies; only message in thread
From: Linus Wallgren @ 2019-12-21 13:22 UTC (permalink / raw)
To: wireguard; +Cc: Linus Wallgren
Signed-off-by: Linus Wallgren <linus.wallgren@gmail.com>
---
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
WireGuard@lists.zx2c4.com
https://lists.zx2c4.com/mailman/listinfo/wireguard
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-12-26 15:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-21 13:22 [PATCH] reresolve-dns: Add systemd-networkd support Linus Wallgren
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).