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