wireguard: add protocol dependency for endpoints
authordanrl <mail@danrl.com>
Tue, 20 Dec 2016 10:06:56 +0000 (11:06 +0100)
committerYousong Zhou <yszhou4tech@gmail.com>
Sat, 24 Dec 2016 06:33:00 +0000 (14:33 +0800)
Endpoint dependency implemented. The actual endpoint is used exclusively. Using
this approach we are dual-stack safe (not errors on missing protocol) and create
only the dependency that are really necessary.

Signed-off-by: Dan Luedtke <mail@danrl.com>
net/wireguard/Makefile
net/wireguard/files/wireguard.sh

index 4a9101757da78a822ac9fa8b6285135f8f2d5167..62d7e8593a7a862f69226bfa2414cf5e20ec5e06 100644 (file)
@@ -11,7 +11,7 @@ include $(INCLUDE_DIR)/kernel.mk
 PKG_NAME:=wireguard
 
 PKG_VERSION:=0.0.20161218
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=WireGuard-$(PKG_VERSION).tar.xz
 # This is actually SHA256, but OpenWRT/LEDE will figure it out based on the length
@@ -34,7 +34,8 @@ define Package/wireguard/Default
   SECTION:=net
   CATEGORY:=Network
   URL:=https://www.wireguard.io
-  MAINTAINER:=Baptiste Jonglez <openwrt@bitsofnetworks.org>
+  MAINTAINER:=Baptiste Jonglez <openwrt@bitsofnetworks.org>, \
+              Dan Luedtke <mail@danrl.com>
 endef
 
 define Package/wireguard/Default/description
@@ -71,7 +72,7 @@ endef
 define Package/wireguard-tools
   $(call Package/wireguard/Default)
   TITLE:=Wireguard userspace control program (wg)
-  DEPENDS:=+libmnl +resolveip
+  DEPENDS:=+libmnl
 endef
 
 define Package/wireguard-tools/description
index 67fd1d1f88399a547781ee9dcfae434ff5dda7cc..1235f23a295142eabd9a345c58acf4e492fe6199 100644 (file)
@@ -83,27 +83,6 @@ proto_wireguard_setup_peer() {
       esac
     done
   fi
-
-  #### FEATURE DISABLED
-  # proto_add_host_dependency() has failed with IPv6 addresses during tests.
-  # Endpoint dependency feature is disabled until the issue is fixed.
-  ####
-  #  # endpoint dependency
-  #  if [ "${endpoint_host}" ]; then
-  #    endpoint_dependency=0
-  #    for ip in $(resolveip -t 10 "${endpoint_host}"); do
-  #      echo "adding host depedency for ${ip} at ${config}"
-  #      proto_add_host_dependency "${config}" "${ip}"
-  #      endpoint_dependency=1
-  #    done
-  #    if [ ${endpoint_dependency} -eq 0 ]; then
-  #      echo "error resolving ${endpoint_host}!"
-  #      sleep 5
-  #      proto_setup_failed "${config}"
-  #      exit 1
-  #    fi
-  #  fi
-  ####
 }
 
 
@@ -161,6 +140,13 @@ proto_wireguard_setup() {
     exit 1
   fi
 
+  # endpoint dependency
+  wg show "${config}" endpoints | while IFS=$'\t:' read -r key ip port; do
+    [ -n "${port}" ] || continue
+    echo "adding host depedency for ${ip} at ${config}"
+    proto_add_host_dependency "${config}" "${ip}"
+  done
+
   proto_send_update "${config}"
 }