dapr / dapr/components-contrib
IPv6 preferred over IPv4 in mDNS
- Dominant language
- Go
- Stars
- 602
- Forks
- 580
- Avg merge
- 4d 9h
- Merged PRs (30d)
- 6
Description
Based on the code in the following lines :
```go
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
Contributor guide
Research direction
Start with components-contrib/nameresolution/mdns/mdns.go around lines 708-719 and trace how IPv4 and IPv6 addresses are passed to onEach(). Reproduce the case where both address types are available, then confirm the expected preference and whether selecting one interface is in scope. Done means the behavior and any selection mechanism are agreed and covered by relevant tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- networking
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100