Browse Source

exclude static route with via ip in route helper (#1791)

When adding Routes to zerotier's Managed Routes, the helper will
add a route rule to the device that does not have a via ip,
so that the address of the Destination segment cannot be routed
correctly within the container.
Here, based on the contents of the routes key in
`zerotier-cli -j listnetworks`,
by determining whether the via key has an ip address,
if it is not null, helper will no longer add route rules.
zwf 2 years ago
parent
commit
15cfa3bf62
1 changed files with 2 additions and 1 deletions
  1. 2 1
      pkg/synology/dsm7-docker/entrypoint.sh

+ 2 - 1
pkg/synology/dsm7-docker/entrypoint.sh

@@ -55,6 +55,7 @@ do
             for ((k=0; k<=$((ROUTE_COUNT-1)); k++))
             do
                 ROUTE="$(jq -r '.['$j'].routes['$k'].target' <<< "$NETWORK_LIST")"
+                VIA="$(jq -r '.['$j'].routes['$k'].via' <<< "$NETWORK_LIST")"
                 if [[ -n "$ROUTE" ]]
                 then
                     # check if route is default and allowDefault enabled for this network
@@ -63,7 +64,7 @@ do
                       continue
                     fi
                     EXIST="$(ip -o route show "$ROUTE")"
-                    if [[ -z "${EXIST}" ]]
+                    if [[ -z "${EXIST}" && "$VIA" == "null" ]]
                     then
                         IFNAME="$(jq -r '.['$j'] | .portDeviceName' <<< "$NETWORK_LIST")"
                         echo " Adding route $ROUTE to dev $IFNAME"