Skip to content

Commit

Permalink
fixup! Upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielius1922 committed May 1, 2024
1 parent 6ddc368 commit f985e86
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions net/connUDP_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,29 +284,38 @@ func TestControlMessageString(t *testing.T) {
func getIfaceAddr(t *testing.T, iface net.Interface, ipv4 bool) net.IP {
addrs, err := iface.Addrs()
require.NoError(t, err)
require.NotEmpty(t, addrs)
var ipOut net.IP
for _, addr := range addrs {
ip, _, err := net.ParseCIDR(addr.String())
require.NoError(t, err)
if !ip.IsPrivate() {
continue
}
if ipv4 {
if ip.To4() != nil {
return ip
}
if ipv4 && ip.To4() == nil {
continue
}
return ip
ipOut = ip
break
}
require.NotEmpty(t, ipOut)
return ipOut
}

func isActiveMulticastInterface(iface net.Interface) bool {
if iface.Name == "anpi0" || iface.Name == "anpi1" { // special debugging interfaces on macOS
return false
}
return nil
return iface.Flags&net.FlagUp == net.FlagUp && iface.Flags&net.FlagMulticast == net.FlagMulticast && iface.Flags&net.FlagLoopback != net.FlagLoopback
}

func TestUDPConnWriteToAddr(t *testing.T) {
ifaces, err := net.Interfaces()
require.NoError(t, err)
var iface net.Interface
for _, i := range ifaces {
if i.Flags&net.FlagUp == net.FlagUp && i.Flags&net.FlagMulticast == net.FlagMulticast && i.Flags&net.FlagLoopback != net.FlagLoopback {
t.Logf("interface name:%v, flags: %v", i.Name, i.Flags)
if isActiveMulticastInterface(i) {
iface = i
break
}
Expand Down

0 comments on commit f985e86

Please sign in to comment.