From c563bc848ee5fbd41a35e805ec90207aee62b081 Mon Sep 17 00:00:00 2001 From: bobbypage Date: Sun, 13 Sep 2020 01:07:06 +0000 Subject: [PATCH] Only set ipv6 killswitch if ipv6 interface exists --- entrypoint.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index d2305ec..4f3b1d7 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -3,7 +3,7 @@ set -e configs=`find /etc/wireguard -type f -printf "%f\n"` -if [[ -z $configs ]]; then +if [[ -z "$configs" ]]; then echo "No configuration files found in /etc/wireguard" >&2 exit 1 fi @@ -18,8 +18,12 @@ docker_network_rule=$([ ! -z "$docker_network" ] && echo "! -d $docker_network" iptables -I OUTPUT ! -o $interface -m mark ! --mark $(wg show $interface fwmark) -m addrtype ! --dst-type LOCAL $docker_network_rule -j REJECT docker6_network="$(ip -o addr show dev eth0 | awk '$3 == "inet6" {print $4}')" -docker6_network_rule=$([ ! -z "$docker6_network" ] && echo "! -d $docker6_network" || echo "") -ip6tables -I OUTPUT ! -o $interface -m mark ! --mark $(wg show $interface fwmark) -m addrtype ! --dst-type LOCAL $docker6_network_rule -j REJECT +if [[ -z "$docker6_network" ]]; then + echo "Skipping ipv6 killswitch setup since ipv6 interface was not found..." >&2 +else + docker6_network_rule=$([ ! -z "$docker6_network" ] && echo "! -d $docker6_network" || echo "") + ip6tables -I OUTPUT ! -o $interface -m mark ! --mark $(wg show $interface fwmark) -m addrtype ! --dst-type LOCAL $docker6_network_rule -j REJECT +fi shutdown () { wg-quick down $interface