fix(inputs.http_response): Fix for IPv4 and IPv6 addresses when interface is set#15496
Merged
powersj merged 4 commits intoinfluxdata:masterfrom Jun 13, 2024
Merged
fix(inputs.http_response): Fix for IPv4 and IPv6 addresses when interface is set#15496powersj merged 4 commits intoinfluxdata:masterfrom
powersj merged 4 commits intoinfluxdata:masterfrom
Conversation
srebhan
reviewed
Jun 12, 2024
Member
srebhan
left a comment
There was a problem hiding this comment.
Awesome work @zak-pawel! Just a few small comments...
Contributor
|
Download PR build artifacts for linux_amd64.tar.gz, darwin_arm64.tar.gz, and windows_amd64.zip. 📦 Click here to get additional PR build artifactsArtifact URLs |
powersj
approved these changes
Jun 13, 2024
Mic92
reviewed
Jul 6, 2024
| } | ||
| } | ||
|
|
||
| return nil, fmt.Errorf("cannot create local address for interface %q and server address %q", interfaceName, address.String()) |
Contributor
There was a problem hiding this comment.
This seems to break the case when the address is a hostname (in my case pointing to an ipv6 address) instead of an ip address:
Error running agent: could not initialize input inputs.http_response: cannot create local address for interface "tinc.retiolum" and server address "http://transmission.r/transmission/web/"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR solves the problem that existed in the scenario where the
urlslist contains mix of IPv4 and IPv6 addresses and theinterfaceis config file set.Until now, the plugin chooses the first available address for the given interface. In my case, it was IPv6 for Windows and IPv4 for Linux. Because of this, the plugin worked incorrectly with IPv4 addresses for Windows and IPv6 addresses for Linux.
Here is a list of the most important things done in this PR:
Each
URLnow has its ownhttpClient(until now, onehttpClientwas used to handle allURLs).Each
URLprovided in the config and each address for the giveninterfacein the config is parsed and checked to see if it is an IPv4 or IPv6 address.url.URLandnet.IPNet. That's why I added github.com/seancfoley/ipaddress-go lib. The topic of parsing addresses is complex enough that I didn't see the point in doing it myself. If any of the reviewers have an idea on how to do this better, I would be happy to hear it :)Each
URLhas ahttpClientassigned that matches the address format (IPv4 or IPv6).Configuration checking and initializing defaults have been moved from
GathertoInit.h.ResponseStringMatchfailsURLsprovided in the config cannot be parsedURLsprovided in the config is not of typehttporhttpshttpClientfor theURL(previously, these errors could occur in
Gather, which did not cause the plugin to fail, but rather resulted in recurring errors in the logs)Thanks to this PR, the
http_responseplugin tests forWindowsare re-enabled.Checklist
Related issues
resolves #8451