Allow generating candidates for both local and external addresses #631
+294
−175
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.
Description
PR makes some changes to
externalIPMapper
in order to allow us to generate an additional candidate for a local IP in case the same address is already mapped to an external one.Before this PR, a mapping such as
[]string{"EA/IA", "IA/IA"}
would throw an error since the internal address appears twice. With this PR, that same mapping should be allowed and generate two candidates, one with the external address and one with the local address.To do this we are converting the
findExternalIP
methods tofindExternalIPs
and return a slice which we iterate on. I tried to avoid changing the logic too much so the changes should be backwards compatible. That means that we are still allowing only one external IP for a given local IP.That said, I am not very experienced with this logic so I'd like to discuss with people more familiar with the code base whether the proposed changes make sense and if there could be edge cases in which this addition may not work as desired.
The original discussion along with a practical example can be found at https://gophers.slack.com/archives/CAK2124AG/p1701379410647329