Questions about healthcheck #613
-
Hi there. Just started using your docker image and it's fantastic! It's saved me a few headaches setting up some new containers. Have a few questions about the healthcheck that I was hoping you could shed some light on
gluetun/internal/healthcheck/health.go Lines 47 to 52 in 87f4b9e I run Adguard Home for my dns resolver (similar to PiHole but with built-in DoH, DoT, DoQ, DNSCrypt so not afraid of DNS leakage) and have been noticing
gluetun/internal/healthcheck/health.go Lines 66 to 71 in d4ca5cf But with the default unbound caching (or Adguard Home in my case or PiHole), wont it just return the cached value and not actually test outbound connections past the first hit? Maybe pinging a well-known dns server (1.1.1.1, 9.9.9.9, 8.8.8.8, 4.2.2.2) might be better? Ping packets are so small that it shouldn't really congest at all and should be fairly decent in terms of privacy.
Thanks again and stay safe my 🇨🇦 brother |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hi there! Thanks for the detailed discussion and digging through the code! The healthcheck code as you've seen does a dns resolution to The healthcheck code runs every 5s when it's stable/healthy, and every second if it encountered a failure, until it succeeds. Now these times are independent from the VPN durations. I have to admit, I got confused myself looking at the code for a solid 2 minutes. It's set here initially: gluetun/internal/healthcheck/server.go Line 35 in 87f4b9e If it succeeds, it's reset here: gluetun/internal/healthcheck/health.go Line 26 in 87f4b9e If it fails for the first time: gluetun/internal/healthcheck/health.go Line 30 in 87f4b9e If it fails after the initial time ( gluetun/internal/healthcheck/openvpn.go Lines 17 to 23 in 87f4b9e Finally, the healthcheck HTTP server/client system is a bit convoluted but it works nicely! With the idea to one day have gluetun a single binary, see #588 and base that image on The Docker healthcheck run a second ephemeral gluetun instance as a healthcheck client: Line 173 in 87f4b9e The client does a request to long running gluetun instance at gluetun/internal/healthcheck/client.go Lines 32 to 48 in 87f4b9e Which hits the HTTP server handler you saw, returning a status code All this is a bit convoluted I agree, but is designed to detect a bad connection quickly (report to the Docker healthcheck and HTTP server) but still wait long enough (and longer with each failure) for the VPN loop which usually takes about 4-5 seconds to setup (👀 Looking at you Openvpn, Wireguard takes 1 second or less). TODOSNow things I need to change:
Also thanks for:
If you feel like contributing anything you feel like, you can use the dev container to setup your Go environment and get started. Let me know though, right now I push to master like a 🐷, I'm happy to do PRs if you want to contribute 😄 Cheers from Montreal! (also not Canadian, but aspiring to!) |
Beta Was this translation helpful? Give feedback.
-
Definitely. It's Go that adopted this strange switch/select way. All other languages I know of need break statements or they'll fallthrough, whereas Go is the opposite, since you need to specify it to fallthrough. As in I don't dislike it, it's just unusual.
Definitely. On top of that you sort of need DoT to resolve the DoH url from time to time. My only issue personally is that everyone can see I'm using DoT on port 853, whereas DoH goes unnoticed (although no traffic on port 53 would point to it too).
Please create a quick copy pasta issue on that github.com/qdm12/dns repo, I'll add that! Maybe post v2.0.0 though. Right now I'm working on DNSSEC to finally merge that beta branch, and it's a PITA 😅 I might get started on adding an http server api to control the DNS (like clear the cache elements). A UI would be nice too, of course. |
Beta Was this translation helpful? Give feedback.
Hi there! Thanks for the detailed discussion and digging through the code!
The healthcheck code as you've seen does a dns resolution to
github.com
. You are right about the DNS cache, I was exactly thinking about it this morning. See the TODOs 1. below.The healthcheck code runs every 5s when it's stable/healthy, and every second if it encountered a failure, until it succeeds. Now these times are independent from the VPN durations. I have to admit, I got confused myself looking at the code for a solid 2 minutes.
It's set here initially:
gluetun/internal/healthcheck/server.go
Line 35 in 87f4b9e
If it succeeds, it's reset here:
gluetu…