shadow1ng/fscan · error
parser_ip_range_failed: %w
Error message
parser_ip_range_failed: %w
What it means
newHostSource fails when a host expression containing '-' and looking like an IP range cannot be parsed by newRangeHostSource, wrapping the parse error with an i18n message. It indicates a malformed IP range in the target specification.
Source
Thrown at common/parsers/host_iterator.go:313
func newHostSource(host string) (hostSource, error) {
switch {
case host == "192":
return newCIDRHostSource("192.168.0.0/16")
case host == "172":
return newCIDRHostSource("172.16.0.0/12")
case host == "10":
return newCIDRHostSource("10.0.0.0/8")
case strings.Contains(host, "/"):
src, err := newCIDRHostSource(host)
if err != nil {
return nil, fmt.Errorf(i18n.Tr("parser_cidr_failed", host)+": %w", err)
}
return src, nil
case strings.Contains(host, "-") && !strings.Contains(host, ":") && looksLikeIPRange(host):
src, err := newRangeHostSource(host)
if err != nil {
return nil, fmt.Errorf(i18n.Tr("parser_ip_range_failed", host)+": %w", err)
}
return src, nil
default:
return &singleHostSource{host: host}, nil
}
}
func newCIDRHostSource(cidr string) (hostSource, error) {
_, ipNet, err := net.ParseCIDR(cidr)
if err != nil {
return nil, err
}
start, ok := ipToUint32(ipNet.IP)
if !ok {
return nil, fmt.Errorf("%s", i18n.GetText("parser_ipv4_only"))
}
ones, bits := ipNet.Mask.Size()View on GitHub (pinned to 95cc12e753)
Solutions
- Correct the range: valid IPs and start <= end, e.g. 192.168.1.1-192.168.1.254
- Validate endpoints with net.ParseIP before passing
- Check the wrapped error to see the exact parse failure
Example fix
// before "192.168.1.10-192.168.1.2" // reversed // after "192.168.1.2-192.168.1.10"
Defensive patterns
Strategy: validation
Validate before calling
if strings.Contains(target, "-") {
parts := strings.SplitN(target, "-", 2)
a, b := net.ParseIP(parts[0]), net.ParseIP(parts[1])
if a == nil || b == nil || compareIP(a, b) > 0 {
return fmt.Errorf("invalid IP range %q", target)
}
} Try / catch
srcs, err := newHostSources(targets)
if err != nil {
if strings.Contains(err.Error(), "parser_ip_range_failed") {
log.Fatalf("fix IP range: %v", err)
}
} Prevention
- Ensure range start <= end and both endpoints are valid IPs
- Avoid octets above 255 and truncated tails
- Sanitize copy-pasted target lists before use
When it happens
Trigger: Passing ranges like '192.168.1.5-192.168.1.2' (start > end), '192.168.1.5-999', or truncated tails where looksLikeIPRange passed but parsing failed.
Common situations: Typos in range endpoints; octet values above 255; reversed start/end; truncated copy-paste of a range.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- parser_invalid_ip_end_val
- parser_invalid_ip_range_val
- parser_cidr_failed: %w
- parser_start_gt_end
- parser_invalid_ip_fmt
AI-assisted analysis of shadow1ng/fscan@95cc12e753 (2026-09-06).
Data as JSON: /api/errors/9d51d9e44a4b8dda.
Report an issue: GitHub.