(s string)
| 207 | } |
| 208 | |
| 209 | func parseIPPort(s string) (net.IP, uint16, error) { |
| 210 | var ( |
| 211 | ip net.IP |
| 212 | err error |
| 213 | ) |
| 214 | |
| 215 | switch len(s) { |
| 216 | case 13: |
| 217 | ip, err = hex.DecodeString(s[0:8]) |
| 218 | if err != nil { |
| 219 | return nil, 0, err |
| 220 | } |
| 221 | case 46: |
| 222 | ip = net.ParseIP(s[1:40]) |
| 223 | if ip == nil { |
| 224 | return nil, 0, fmt.Errorf("%w: Invalid IPv6 addr %s: %w", ErrFileParse, s[1:40], err) |
| 225 | } |
| 226 | default: |
| 227 | return nil, 0, fmt.Errorf("%w: Unexpected IP:Port %s: %w", ErrFileParse, s, err) |
| 228 | } |
| 229 | |
| 230 | portString := s[len(s)-4:] |
| 231 | if len(portString) != 4 { |
| 232 | return nil, 0, |
| 233 | fmt.Errorf("%w: Unexpected port string format %s: %w", ErrFileParse, portString, err) |
| 234 | } |
| 235 | port, err := strconv.ParseUint(portString, 16, 16) |
| 236 | if err != nil { |
| 237 | return nil, 0, err |
| 238 | } |
| 239 | |
| 240 | return ip, uint16(port), nil |
| 241 | } |
no outgoing calls
searching dependent graphs…