| 41 | } |
| 42 | |
| 43 | func (ipSet *IPSet) Contains(ip net.IP, isLog bool, name string) bool { |
| 44 | result := false |
| 45 | if ipSet != nil { |
| 46 | if ipv4 := ip.To4(); ipv4 != nil { |
| 47 | result = ipSet.ipv4.contains(ipv4) |
| 48 | } else if ipv6 := ip.To16(); ipv6 != nil { |
| 49 | result = ipSet.ipv6.contains(ipv6) |
| 50 | } |
| 51 | if result && isLog { |
| 52 | log.Debugf("Matched: IP network %s %s", name, ip.String()) |
| 53 | } |
| 54 | } else { |
| 55 | log.Debug("IP network list is nil, not checking") |
| 56 | } |
| 57 | return result |
| 58 | } |
| 59 | |
| 60 | func toRange(ip net.IP, mask net.IPMask) *ipRange { |
| 61 | // assert len(ip) == len(mask) |