//go:build !darwin && !windows package dns import ( "net" "golang.org/x/net/ipv4" "golang.org/x/net/ipv6" ) func setUDPSocketOptions(conn *net.UDPConn) error { // Try setting the flags for both families and ignore the errors unless they // both error. err6 := ipv6.NewPacketConn(conn).SetControlMessage(ipv6.FlagDst|ipv6.FlagInterface, true) err4 := ipv4.NewPacketConn(conn).SetControlMessage(ipv4.FlagDst|ipv4.FlagInterface, true) if err6 != nil && err4 != nil { return err4 } return nil }