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.
This commit is contained in:
zwf 2023-01-21 03:57:13 +08:00 committed by GitHub
parent 9c9d1650d1
commit 15cfa3bf62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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"