From 19330ac555f470b65ca38cfb4d821036382e6e58 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Sun, 31 Oct 2021 01:24:52 -0500 Subject: [PATCH] r/protonvpn: watchdog: reconfigure at startup If the remote address configuration for strongSwan is not valid when the Proton VPN watchdog starts, it will now regenerate it immediately. This can happen, for example, if the Internet has been down for a while, and the watchdog has iterated through all of the servers in the cache. Restarting the service will now force it to reconfigure the tunnel and bring the VPN back up. --- roles/protonvpn/files/protonvpn-watchdog.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/roles/protonvpn/files/protonvpn-watchdog.py b/roles/protonvpn/files/protonvpn-watchdog.py index eee6ba4..93f5315 100644 --- a/roles/protonvpn/files/protonvpn-watchdog.py +++ b/roles/protonvpn/files/protonvpn-watchdog.py @@ -174,6 +174,16 @@ class AsyncDaemon(BaseAsyncDaemon): async def manage_serverlist(self) -> None: while 1: self.serverlist = await self.get_serverlist() + try: + st = os.stat(self.CONFIG) + except FileNotFoundError: + await self.reconfigure() + except OSError as e: + log.error('Error checking config file attributes: %s', e) + await self.reconfigure() + else: + if st.st_size < 10: + await self.reconfigure() await asyncio.sleep(3600 + random.randint(0, 900)) def mark_bad(self, addr: str) -> None: