components-contrib icon indicating copy to clipboard operation
components-contrib copied to clipboard

IPv6 preferred over IPv4 in mDNS

Open mukundansundar opened this issue 2 years ago • 4 comments

Based on the code in the following lines :

			if hasIPv4Address {
				addr = fmt.Sprintf("%s:%d", entry.AddrIPv4[0].String(), port)
				m.addAppAddressIPv4(appID, addr)
			}
			if hasIPv6Address {
				addr = fmt.Sprintf("%s:%d", entry.AddrIPv6[0].String(), port)
				m.addAppAddressIPv6(appID, addr)
			}

			if onEach != nil {
				onEach(addr) // invoke callback.
			}

https://github.com/dapr/components-contrib/blob/master/nameresolution/mdns/mdns.go#L708-L719

It is seen that onEach() is called with the address populated. But when both IPv6 and IPv4 addresses are available for an application, IPv6 is given preference over IPv4 ...

Is this the expected behavior or should it be changed. As a follow up should there be some way to select only one interface to use when both are available?

cc @jjcollinge

mukundansundar avatar Mar 21 '22 18:03 mukundansundar

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue, help wanted or triaged/resolved) or other activity occurs. Thank you for your contributions.

dapr-bot avatar Apr 20 '22 18:04 dapr-bot

This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as pinned, good first issue, help wanted or triaged/resolved. Thank you for your contributions.

dapr-bot avatar Apr 27 '22 18:04 dapr-bot

@yaron2 @jjcollinge Can you comment on whether this the expected behavior ?

mukundansundar avatar Apr 27 '22 19:04 mukundansundar

I'm not sure about changing the default (happy to if we think it's better to pick IPv4 over IPv6), I think making it possible to configure a preference seems reasonable.

jjcollinge avatar Apr 27 '22 20:04 jjcollinge