Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(client): Add client network configuration for ICMP endpoint clients #661

Merged
merged 9 commits into from Feb 7, 2024

Conversation

n-thumann
Copy link
Contributor

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 #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 golang/go#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. Adding network: "ip6" to the endpoints client config fixes this.

Checklist

  • Tested and/or added tests to validate that the changes work as intended, if applicable.
  • Updated documentation in README.md, if applicable.

Copy link
Owner

@TwiN TwiN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add some tests?

@n-thumann
Copy link
Contributor Author

Could you add some tests?

Done ✌️

@TwiN TwiN added the feature New feature or request label Feb 4, 2024
client/client_test.go Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Feb 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (6cbc59b) 78.51% compared to head (4d2cb75) 78.57%.

❗ 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     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

README.md Outdated Show resolved Hide resolved
@TwiN TwiN merged commit 3d1b4e5 into TwiN:master Feb 7, 2024
2 checks passed
@TwiN
Copy link
Owner

TwiN commented Feb 7, 2024

Thank you for the contribution!

github-merge-queue bot pushed a commit to chezmoi-sh/nex.rpi that referenced this pull request Mar 23, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Update | Change | OpenSSF |
|---|---|---|---|
| [TwiN/gatus](https://togithub.com/TwiN/gatus) | minor | `v5.7.0` ->
`v5.8.0` | [![OpenSSF
Scorecard](https://api.securityscorecards.dev/projects/github.com/TwiN/gatus/badge)](https://securityscorecards.dev/viewer/?uri=github.com/TwiN/gatus)
|

---

### Release Notes

<details>
<summary>TwiN/gatus (TwiN/gatus)</summary>

### [`v5.8.0`](https://togithub.com/TwiN/gatus/releases/tag/v5.8.0)

[Compare
Source](https://togithub.com/TwiN/gatus/compare/v5.7.0...v5.8.0)

##### What's Changed

- feat(client): Add Google's Identity-Aware-Proxy in client config by
[@&#8203;Kloox](https://togithub.com/Kloox) in
[TwiN/gatus#600
- feat(client): Add client network configuration for ICMP endpoint
clients by [@&#8203;n-thumann](https://togithub.com/n-thumann) in
[TwiN/gatus#661
- feat(http): enhance HTTP client configuration with proxy support by
[@&#8203;appleboy](https://togithub.com/appleboy) in
[TwiN/gatus#668
- feat: add ability to delay startup by
[@&#8203;vax-r](https://togithub.com/vax-r) in
[TwiN/gatus#631
- feat: shields.io endpoint badge by
[@&#8203;buroa](https://togithub.com/buroa) in
[TwiN/gatus#652
- fix(web): Allow configuration of read-buffer-size by
[@&#8203;TwiN](https://togithub.com/TwiN) in
[TwiN/gatus#675
- fix: Allow binding IPv6 addresses for web by
[@&#8203;n-thumann](https://togithub.com/n-thumann) in
[TwiN/gatus#650
- build: refine Makefile targets and build command by
[@&#8203;appleboy](https://togithub.com/appleboy) in
[TwiN/gatus#666
- refactor(alerting): Use pointer for receiver in
AlertProvider.GetDefaultAlert method by
[@&#8203;TwiN](https://togithub.com/TwiN) in
[TwiN/gatus#676
- docs(alerting): Fix wrong gitlab terminology (alert key vs. PAT) by
[@&#8203;salim-b](https://togithub.com/salim-b) in
[TwiN/gatus#694
- chore(deps): bump actions/setup-go from 4 to 5 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[TwiN/gatus#634
- chore(deps): bump golang.org/x/crypto from 0.14.0 to 0.18.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[TwiN/gatus#649
- chore(deps): bump modernc.org/sqlite from 1.26.0 to 1.28.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[TwiN/gatus#654
- chore(deps): bump codecov/codecov-action from 3.1.4 to 3.1.6 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[TwiN/gatus#669
- chore(deps): bump codecov/codecov-action from 3.1.6 to 4.0.1 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[TwiN/gatus#671
- chore(deps): bump github.com/prometheus/client_golang from 1.17.0 to
1.18.0 by [@&#8203;dependabot](https://togithub.com/dependabot) in
[TwiN/gatus#658
- chore(deps): bump github.com/gofiber/fiber/v2 from 2.49.2 to 2.52.1 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[TwiN/gatus#682
- chore(deps): bump github.com/TwiN/deepmerge from 0.2.0 to 0.2.1 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[TwiN/gatus#684
- chore(deps): bump golang.org/x/oauth2 from 0.13.0 to 0.18.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[TwiN/gatus#701

##### New Contributors

- [@&#8203;Kloox](https://togithub.com/Kloox) made their first
contribution in
[TwiN/gatus#600
- [@&#8203;n-thumann](https://togithub.com/n-thumann) made their first
contribution in
[TwiN/gatus#650
- [@&#8203;buroa](https://togithub.com/buroa) made their first
contribution in
[TwiN/gatus#652

**Full Changelog**:
TwiN/gatus@v5.7.0...v5.8.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/chezmoi-sh/nex.rpi).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNjEuMCIsInVwZGF0ZWRJblZlciI6IjM3LjI2MS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants