wireguard: new version and usability improvements
authordanrl <mail@danrl.com>
Sat, 14 Jan 2017 13:54:42 +0000 (14:54 +0100)
committerYousong Zhou <yszhou4tech@gmail.com>
Mon, 16 Jan 2017 03:20:07 +0000 (11:20 +0800)
Signed-off-by: Dan Luedtke <mail@danrl.com>
net/wireguard/Makefile
net/wireguard/files/wireguard.sh

index 85ab3c4f98ba508ac926ff97b78e8aa57d6ddbb1..8dacfebc0974a6b7c18870e283724159dbe3418a 100644 (file)
@@ -1,6 +1,7 @@
 #
 # Copyright (C) 2016 Jason A. Donenfeld <Jason@zx2c4.com>
 # Copyright (C) 2016 Baptiste Jonglez <openwrt@bitsofnetworks.org>
+# Copyright (C) 2016-2017 Dan Luedtke <mail@danrl.com>
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
@@ -10,20 +11,19 @@ include $(INCLUDE_DIR)/kernel.mk
 
 PKG_NAME:=wireguard
 
-PKG_VERSION:=0.0.20170105
+PKG_VERSION:=0.0.20170115
 PKG_RELEASE:=1
 
 PKG_SOURCE:=WireGuard-$(PKG_VERSION).tar.xz
-# This is actually SHA256, but OpenWRT/LEDE will figure it out based on the length
-PKG_MD5SUM:=1bd990eeae6fbf599ccddde81caa92770f58623ad9705f875bcfab8254583896
 PKG_SOURCE_URL:=https://git.zx2c4.com/WireGuard/snapshot/
-PKG_BUILD_DIR:=$(BUILD_DIR)/WireGuard-$(PKG_VERSION)
+PKG_MD5SUM:=7e5f9f4699a2d4ace90d0df5d81bf0f67205ee08c45b95e0acc379bedef5ffe8
 
 PKG_LICENSE:=GPL-2.0
 PKG_LICENSE_FILES:=COPYING
 
-PKG_USE_MIPS16:=0
+PKG_BUILD_DIR:=$(BUILD_DIR)/WireGuard-$(PKG_VERSION)
 PKG_BUILD_PARALLEL:=1
+PKG_USE_MIPS16:=0
 
 # Wireguard's makefile needs this to know where to build the kernel module
 export KERNELDIR:=$(LINUX_DIR)
index 1235f23a295142eabd9a345c58acf4e492fe6199..2eb30242a664128a595c0b3d9bf5b7308715ce9e 100644 (file)
@@ -1,5 +1,5 @@
 #!/bin/sh
-# Copyright 2016 Dan Luedtke <mail@danrl.com>
+# Copyright 2016-2017 Dan Luedtke <mail@danrl.com>
 # Licensed to the public under the Apache License 2.0.
 
 
@@ -100,6 +100,7 @@ proto_wireguard_setup() {
   config_load network
   config_get private_key   "${config}" "private_key"
   config_get listen_port   "${config}" "listen_port"
+  config_get addresses     "${config}" "addresses"
   config_get mtu           "${config}" "mtu"
   config_get preshared_key "${config}" "preshared_key"
 
@@ -140,11 +141,31 @@ proto_wireguard_setup() {
     exit 1
   fi
 
+  # add ip addresses
+  for address in ${addresses}; do
+    case "${address}" in
+      *:*/*)
+        proto_add_ipv6_address "${address%%/*}" "${address##*/}"
+      ;;
+      *.*/*)
+        proto_add_ipv4_address "${address%%/*}" "${address##*/}"
+      ;;
+      *:*)
+        proto_add_ipv6_address "${address%%/*}" "128"
+      ;;
+      *.*)
+        proto_add_ipv4_address "${address%%/*}" "32"
+      ;;
+    esac
+  done
+
   # endpoint dependency
-  wg show "${config}" endpoints | while IFS=$'\t:' read -r key ip port; do
+  wg show "${config}" endpoints | \
+    sed -E 's/\[?([0-9.:a-f]+)\]?:([0-9]+)/\1 \2/' | \
+    while IFS=$'\t ' read -r key address port; do
     [ -n "${port}" ] || continue
-    echo "adding host depedency for ${ip} at ${config}"
-    proto_add_host_dependency "${config}" "${ip}"
+    echo "adding host depedency for ${address} at ${config}"
+    proto_add_host_dependency "${config}" "${address}"
   done
 
   proto_send_update "${config}"