wireguard: do not add host-dependencies if fwmark is set
authorDaniel Golle <daniel@makrotopia.org>
Tue, 19 Mar 2019 15:47:17 +0000 (16:47 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Wed, 27 Mar 2019 21:53:14 +0000 (22:53 +0100)
The 'fwmark' option is used to define routing traffic to
wireguard endpoints to go through specific routing tables.
In that case it doesn't make sense to setup routes for
host-dependencies in the 'main' table, so skip setting host
dependencies if 'fwmark' is set.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
package/network/services/wireguard/files/wireguard.sh

index 96fa721..58e47f9 100644 (file)
@@ -176,12 +176,14 @@ proto_wireguard_setup() {
   done
 
   # endpoint dependency
-  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
-    proto_add_host_dependency "${config}" "${address}"
-  done
+  if [ ! "${fwmark}" ]; then
+    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
+      proto_add_host_dependency "${config}" "${address}"
+    done
+  fi
 
   proto_send_update "${config}"
 }