| 1 |
//go:build !darwin && !windows |
| 2 |
|
| 3 |
package dns |
| 4 |
|
| 5 |
import ( |
| 6 |
"net" |
| 7 |
|
| 8 |
"golang.org/x/net/ipv4" |
| 9 |
"golang.org/x/net/ipv6" |
| 10 |
) |
| 11 |
|
| 12 |
func setUDPSocketOptions(conn *net.UDPConn) error { |
| 13 |
// Try setting the flags for both families and ignore the errors unless they |
| 14 |
// both error. |
| 15 |
err6 := ipv6.NewPacketConn(conn).SetControlMessage(ipv6.FlagDst|ipv6.FlagInterface, true) |
| 16 |
err4 := ipv4.NewPacketConn(conn).SetControlMessage(ipv4.FlagDst|ipv4.FlagInterface, true) |
| 17 |
if err6 != nil && err4 != nil { |
| 18 |
return err4 |
| 19 |
} |
| 20 |
return nil |
| 21 |
} |