wireguard: add protocol dependency for endpoints

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>
This commit is contained in:
danrl
2016-12-24 14:33:00 +08:00
committed by Yousong Zhou
parent 333957fba9
commit 7d34e8e5f4
2 changed files with 11 additions and 24 deletions
+7 -21
View 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}"
}