Skip to content

Commit

Permalink
mdns: if host does not support IPv6, disable mDNS IPv6 networking
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Mougard <[email protected]>
  • Loading branch information
gabrielmougard committed Apr 30, 2024
1 parent 508cd83 commit 1b75f96
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion microcloud/mdns/lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,26 @@ func Lookup(ctx context.Context, iface *net.Interface, service string, size int)
params.Interface = iface
params.Entries = entriesCh
params.Timeout = 100 * time.Millisecond
err := mdns.Query(params)
ipv4Supported, ipv6Supported, err := checkIPStatus(iface.Name)
if err != nil {
return nil, fmt.Errorf("Failed to check IP status: %w", err)
}

if !ipv4Supported {
logger.Infof("IPv4 is not supported on this system network interface %q: disabling IPv4 mDNS\n", iface.Name)
params.DisableIPv4 = true
}

if !ipv6Supported {
logger.Infof("IPv6 is not supported on this system network interface %q: disabling IPv6 mDNS\n", iface.Name)
params.DisableIPv6 = true
}

if params.DisableIPv4 && params.DisableIPv6 {
return nil, fmt.Errorf("No supported IP versions on the network interface %q", iface.Name)
}

err = mdns.Query(params)
if err != nil {
return nil, fmt.Errorf("Failed lookup: %w", err)
}
Expand Down

0 comments on commit 1b75f96

Please sign in to comment.