gatus
gatus copied to clipboard
feat(client): Add client network configuration for ICMP endpoint clients
Summary
This PR adds support to explicitly specify the network to use for ICMP endpoint clients, e.g. IPv6. In the future, this may be extended to also support HTTPS endpoints (requested https://github.com/TwiN/gatus/issues/185).
Details
I decided to use ping.NewPinger
instead of ping.New
, because the latter automatically resolves the address before we can set the desired network.
I set ip
as the default config value. This is technically not needed and could be an empty string, because SetNetwork
takes care of it anyways, but I think it's a cleaner approach.
Background
I am running Gatus on an IPv6-only machine. Sadly, net.ResolveIPAddr
still returns a single IPv4 address, when being asked to resolve a dual-stacked host (see https://github.com/golang/go/issues/28666). Pinging the returned IPv4 address from Gatus will obviously fail on an IPv6-only host.
I confirmed this by:
- Adding
ipv6.google.com
as an ICMP endpoint: This works by default on an IPv6-only host, because this target is IPv6-only anyways - Adding
google.com
as an ICMP endpoint: This doesn't work by default on an IPv6-only host, because this target is dual-stacked and Gatus tries to ping via IPv4. Addingnetwork: "ip6"
to the endpoints client config fixes this.
Checklist
- [x] Tested and/or added tests to validate that the changes work as intended, if applicable.
- [x] Updated documentation in
README.md
, if applicable.
Could you add some tests?
Done :v:
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Comparison is base (
6cbc59b
) 78.51% compared to head (4d2cb75
) 78.57%.
:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@ Coverage Diff @@
## master #661 +/- ##
==========================================
+ Coverage 78.51% 78.57% +0.05%
==========================================
Files 58 58
Lines 4748 4746 -2
==========================================
+ Hits 3728 3729 +1
+ Misses 833 831 -2
+ Partials 187 186 -1
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Thank you for the contribution!