Skip to content

Commit 15b54ae

Browse files
committed
Code refactoring for #1283
1 parent efb1ae1 commit 15b54ae

File tree

1 file changed

+0
-43
lines changed

1 file changed

+0
-43
lines changed

pkg/mdns/client.go

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,6 @@ func (b *Browser) ListenMulticastUDP() error {
192192
for _, ipn := range nets {
193193
conn, err := lc1.ListenPacket(ctx, "udp4", ipn.IP.String()+":5353") // same port important
194194
if err != nil {
195-
if strings.Contains(err.Error(), "address already in use") {
196-
continue
197-
}
198195
continue
199196
}
200197
b.Nets = append(b.Nets, ipn)
@@ -380,43 +377,3 @@ func NewServiceEntries(msg *dns.Msg, ip net.IP) (entries []*ServiceEntry) {
380377

381378
return
382379
}
383-
384-
func InterfacesIP4() ([]net.IP, error) {
385-
intfs, err := net.Interfaces()
386-
if err != nil {
387-
return nil, err
388-
}
389-
390-
var ips []net.IP
391-
392-
loop:
393-
for _, intf := range intfs {
394-
if intf.Flags&net.FlagUp == 0 || intf.Flags&net.FlagLoopback != 0 {
395-
continue
396-
}
397-
398-
addrs, err := intf.Addrs()
399-
if err != nil {
400-
continue
401-
}
402-
403-
for _, addr := range addrs {
404-
switch v := addr.(type) {
405-
case *net.IPNet:
406-
if ip := v.IP.To4(); ip != nil {
407-
if ip.IsLinkLocalUnicast() {
408-
continue
409-
}
410-
ips = append(ips, ip)
411-
continue loop
412-
}
413-
}
414-
}
415-
}
416-
417-
if len(ips) == 0 {
418-
return nil, errors.New("no IPv4 addresses found")
419-
}
420-
421-
return ips, nil
422-
}

0 commit comments

Comments
 (0)