pion / ice

A Go implementation of ICE
https://pion.ly/
MIT License
430 stars 158 forks source link

Allow generating candidates for both local and external addresses #631

Open streamer45 opened 9 months ago

streamer45 commented 9 months ago

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 to findExternalIPs 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

streamer45 commented 9 months ago

@cnderrauber @stv0g Not urgent but would love your feedback if you have a chance to look at this. Thank you!

/cc @Sean-Der