mirror of https://github.com/k3s-io/k3s
Also remove the wg-add script that has been unused since v1.26 dropped the legacy wireguard backend
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit 047664b610
)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
pull/10540/head
parent
b4b156d9d1
commit
5c81c715bf
@ -1,34 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
auto-mtu() {
|
|
||||||
local mtu=0 endpoint output
|
|
||||||
while read -r _ endpoint; do
|
|
||||||
[[ $endpoint =~ ^\[?([a-z0-9:.]+)\]?:[0-9]+$ ]] || continue
|
|
||||||
output="$(ip route get "${BASH_REMATCH[1]}" || true)"
|
|
||||||
[[ ( $output =~ mtu\ ([0-9]+) || ( $output =~ dev\ ([^ ]+) && $(ip link show dev "${BASH_REMATCH[1]}") =~ mtu\ ([0-9]+) ) ) && ${BASH_REMATCH[1]} -gt $mtu ]] && mtu="${BASH_REMATCH[1]}"
|
|
||||||
done < <(wg show "$1" endpoints)
|
|
||||||
if [[ $mtu -eq 0 ]]; then
|
|
||||||
read -r output < <(ip route show default || true) || true
|
|
||||||
[[ ( $output =~ mtu\ ([0-9]+) || ( $output =~ dev\ ([^ ]+) && $(ip link show dev "${BASH_REMATCH[1]}") =~ mtu\ ([0-9]+) ) ) && ${BASH_REMATCH[1]} -gt $mtu ]] && mtu="${BASH_REMATCH[1]}"
|
|
||||||
fi
|
|
||||||
[[ $mtu -gt 0 ]] || mtu=1500
|
|
||||||
ip link set mtu $(( mtu - 80 )) up dev "$1"
|
|
||||||
}
|
|
||||||
|
|
||||||
# probe for any modules that may be needed
|
|
||||||
modprobe wireguard
|
|
||||||
modprobe tun
|
|
||||||
|
|
||||||
# try wireguard kernel module first
|
|
||||||
ip link add "$1" type wireguard && exit
|
|
||||||
|
|
||||||
# try boringtun and let it drop privileges
|
|
||||||
boringtun "$1" && auto-mtu "$1" && exit
|
|
||||||
|
|
||||||
# try boringtun w/o dropping privileges
|
|
||||||
WG_SUDO=1 boringtun "$1" && auto-mtu "$1" && exit
|
|
||||||
|
|
||||||
# try wireguard-go - p.s. should not use wireguard-go, it leaks memory
|
|
||||||
WG_I_PREFER_BUGGY_USERSPACE_TO_POLISHED_KMOD=1 wireguard-go "$1" && auto-mtu "$1" && exit
|
|
||||||
|
|
||||||
exit 1
|
|
Loading…
Reference in new issue