Commit Graph

6 Commits (master)

Author SHA1 Message Date
Dustin b7bbafd189 r/protonvpn: Move remote_addrs file to /var
If `/` is mounted read-only, as is usually the case, the Proton VPN
watchdog cannot update the `remote_addrs` configuration file.  It needs
to be stored in a directory that is guaranteed to be writable.
2022-08-20 18:18:21 -05:00
Dustin 5e2cfee8a1 r/protonvpn: watchdog: Improve error handling
This resolves two issues with fetching the Proton VPNserver list:

1. If a connection error occurs when fetching the list, it will be
   ignored, just as with HTTP errors
2. If any errors are encountered when fetching the list, and a valid
   cache was loaded, its contents are returned, regardless of the
   timestamp of the cache file.
2022-03-01 21:28:21 -06:00
Dustin 19330ac555 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.
2021-10-31 01:24:52 -05:00
Dustin 1fcfc80254 r/protonvpn: watchdog: Also watch for EAP/FAIL
Occasionally, ProtonVPN servers randomly reject the EAP authentication
credentials.  When this happens, the tunnel fails and is not restarted
automatically by strongSwan.  As such, the watchdog needs to react to
this event as well.
2021-06-27 09:23:46 -05:00
Dustin 0add34a9a3 roles/protonvpn: Add watchdog script
One major problem with the current DNS-over-VPN implementation is that
the ProtonVPN servers are prone to random outages.  When the server
we're using goes down, there is not a straightforward way to switch to
another one.  At first I tried creating a fake DNS zone with A records
for each ProtonVPN server, all for the same name.  This ultimately did
not work, but I am not sure I understand why.  strongSwan would
correctly resolve the name each time it tried to connect, and send IKE
initialization requests to a different address each time, but would
reject the responses from all except the first address it used.  The
only way to get it working again was to restart the daemon.

Since strongSwan is apparently not going to be able to handle this kind
of fallback on its own, I decided to write a script to do it externally.
Enter `protonvpn-watchdog.py`.  This script reads the syslog messages
from strongSwan (via the systemd journal, using `journalctl`'s JSON
output) and reacts when it receives the "giving up after X tries"
message.  This message indicates that strongSwan has lost connection to
the current server and has not been able to reestablish it within the
retry period.  When this happens, the script will consult the cached
list of ProtonVPN servers and find the next one available.  It keeps
track of the ones that have failed in the past, and will not connect to
them again, so as not to simply bounce back-and-forth between two
(possibly dead) servers.  Approximately every hour, it will attempt to
refresh the server list, to ensure that the most accurate server scores
and availability are known.
2021-06-21 20:48:23 -05:00
Dustin 8ca093050b pyrocufflink-dns: Cloudflare over ProtonVPN
This commit adds a new playbook, `protonvpn.yml`, and its supporting
roles *strongswan-swanctl* and *protonvpn*.  This playbook configures
strongSwan to connect to ProtonVPN using IPsec/IKEv2.

With this playbook, we configure the name servers on the Pyrocufflink
network to route all DNS requests through the Cloudflare public DNS
recursive servers at 1.1.1.1/1.0.0.1 over ProtonVPN.  Using this setup,
we have the benefit of the speed of using a public DNS server (which is
*significantly* faster than running our own recursive server, usually by
1-2 seconds per request), and the benefit of anonymity from ProtonVPN.

Using the public DNS server alone is great for performance, but allows
the server operator (in this case Cloudflare) to track and analyze usage
patterns.  Using ProtonVPN gives us anonymity (assuming we trust
ProtonVPN not to do the very same tracking), but can have a negative
performance impact if its used for all Internet traffic.  By combining
these solutions, we can get the benefits of both!
2020-09-06 11:06:58 -05:00