Răsfoiți Sursa

Skipping the IPs assigned to interfaces in the DOWN state while resolving `0.0.0.0` in TCP LISTEN sockets (coroot/coroot#22)

Anton Petruhin 3 ani în urmă
părinte
comite
674a5a5ace
1 a modificat fișierele cu 4 adăugiri și 0 ștergeri
  1. 4 0
      proc/ns.go

+ 4 - 0
proc/ns.go

@@ -53,6 +53,10 @@ func GetNsIps(ns netns.NsHandle) ([]netaddr.IP, error) {
 	}
 	var res []netaddr.IP
 	for _, link := range links {
+		attrs := link.Attrs()
+		if attrs.OperState == netlink.OperDown {
+			continue
+		}
 		addrs, err := h.AddrList(link, unix.AF_UNSPEC)
 		if err != nil {
 			return nil, err