(s string)
| 120 | } |
| 121 | |
| 122 | func parseNet(s string) (*net.IPNet, error) { |
| 123 | if strings.Contains(s, "/") { |
| 124 | _, n, err := net.ParseCIDR(s) |
| 125 | if err != nil { |
| 126 | return nil, fmt.Errorf("bad CIDR %q", s) |
| 127 | } |
| 128 | return n, nil |
| 129 | } |
| 130 | ip := net.ParseIP(s) |
| 131 | if ip == nil { |
| 132 | return nil, fmt.Errorf("bad IP %q", s) |
| 133 | } |
| 134 | bits := 128 |
| 135 | if ip.To4() != nil { |
| 136 | ip, bits = ip.To4(), 32 |
| 137 | } |
| 138 | return &net.IPNet{IP: ip, Mask: net.CIDRMask(bits, bits)}, nil |
| 139 | } |
| 140 | |
| 141 | type originKey struct{} |
| 142 |
no outgoing calls
no test coverage detected