mirror of
https://git.openwrt.org/openwrt/openwrt.git
synced 2026-02-18 02:25:27 +01:00
wireguard-tools: detect address changes at reload
Proto handler now also detects changes to
- addresses
Tighten also assign address portion
Signed-off-by: Paul Donald <newtwen+github@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/21784
Signed-off-by: Robert Marko <robimarko@gmail.com>
(cherry picked from commit d59b360cee)
Link: https://github.com/openwrt/openwrt/pull/21840
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
This commit is contained in:
parent
5caf02eba9
commit
61e931db7e
1 changed files with 9 additions and 13 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#!/bin/sh
|
||||
# Copyright 2016-2017 Dan Luedtke <mail@danrl.com>
|
||||
# Licensed to the public under the Apache License 2.0.
|
||||
# shellcheck disable=SC2317
|
||||
|
||||
WG=/usr/bin/wg
|
||||
if [ ! -x $WG ]; then
|
||||
|
|
@ -19,6 +20,8 @@ proto_wireguard_init_config() {
|
|||
proto_config_add_int "listen_port"
|
||||
proto_config_add_int "mtu"
|
||||
proto_config_add_string "fwmark"
|
||||
proto_config_add_string "addresses"
|
||||
|
||||
available=1
|
||||
no_proto_task=1
|
||||
}
|
||||
|
|
@ -173,20 +176,13 @@ proto_wireguard_setup() {
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Assign 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"
|
||||
;;
|
||||
*:*/*) 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
|
||||
|
||||
|
|
@ -194,7 +190,7 @@ proto_wireguard_setup() {
|
|||
proto_add_ipv6_prefix "$prefix"
|
||||
done
|
||||
|
||||
# endpoint dependency
|
||||
# Endpoint dependency tracking
|
||||
if [ "${nohostroute}" != "1" ]; then
|
||||
wg show "${config}" endpoints | \
|
||||
sed -E 's/\[?([0-9.:a-f]+)\]?:([0-9]+)/\1 \2/' | \
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue