From c92471e1f94a505c582de73d9d75a6b0fcdc2767 Mon Sep 17 00:00:00 2001 From: Gautam Korlam Date: Wed, 30 Dec 2020 10:21:56 -0800 Subject: [PATCH 1/2] Fill both expected and actual ips on refresh --- run | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/run b/run index b1178ce..ab28b90 100644 --- a/run +++ b/run @@ -100,14 +100,6 @@ else ip route add to $LOCAL_NETWORK via $gw dev eth0 fi - -# Get the expected VPN IP address from the interface config file -expected_ips=() -for interface in $interfaces; do - expected_ip=$(grep -Po '^Endpoint\s?=\s?\K[0-9\.]{7,}' $interface) - expected_ips+=($expected_ip) -done - # Handle shutdown behavior function finish { echo "$(date): ---INFO--- Shutting down Wireguard" @@ -121,8 +113,14 @@ function finish { exit 0 } -# Fill get the actual IP as reported by wireguard -function fill_actual_ip { +# Fill the expected and actual ips +function fill_ips { + expected_ips=() + for interface in $interfaces; do + expected_ip=$(grep -Po '^Endpoint\s?=\s?\K[0-9\.]{7,}' $interface) + expected_ips+=($expected_ip) + done + actual_ips=() actual_ip=$(wg | grep -Po 'endpoint:\s\K[^:]*') actual_ips+=($actual_ip) @@ -144,7 +142,7 @@ function write_service_hosts { fi } -fill_actual_ip +fill_ips echo "$(date): ---INFO--- Endpoint in config: $expected_ips" echo "$(date): ---INFO--- Active EndPoint : $actual_ips" @@ -156,7 +154,7 @@ while $retry do sleep 10; - fill_actual_ip + fill_ips if [[ $expected_ips != $actual_ips ]]; then # Make one attempt to restart the wireguard interface if the IP is incorrect @@ -165,7 +163,7 @@ do wg-quick down $interface; wg-quick up $interface done - fill_actual_ip + fill_ips if [[ $expected_ips != $actual_ips ]]; then # Exit the container if the IP is still incorrect after wireguard restart From e6d8f6fecb50065f5adb5db7dfae4349cffa17b7 Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 30 Oct 2023 16:14:36 -0400 Subject: [PATCH 2/2] update build to bullseye-slim --- Dockerfile | 6 +++--- run | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1581650..6165709 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ -FROM debian:buster +FROM debian:bullseye-slim # Add debian backports repo for wireguard packages -RUN echo "deb http://deb.debian.org/debian/ buster-backports main" > /etc/apt/sources.list.d/buster-backports.list +RUN echo "deb http://deb.debian.org/debian/ bullseye-backports main" > /etc/apt/sources.list.d/buster-backports.list # Install wireguard packges RUN apt-get update && \ - apt-get install -y --no-install-recommends wireguard-tools iptables nano net-tools procps openresolv docker.io jq dnsmasq curl dnsutils && \ + apt-get install -y --no-install-recommends wireguard-tools iproute2 iptables nano net-tools procps openresolv docker.io jq dnsmasq curl dnsutils && \ apt-get clean # Add main work dir to PATH diff --git a/run b/run index ab28b90..e0f6b7c 100644 --- a/run +++ b/run @@ -148,7 +148,7 @@ echo "$(date): ---INFO--- Active EndPoint : $actual_ips" write_service_hosts -# Check IP address every 10 seconds +Check IP address every 10 seconds retry=true while $retry do