shadow1ng/fscan · error
parser_invalid_end_ip
Error message
parser_invalid_end_ip
What it means
In parseIPRangeString, for full-format ranges (end contains '.'), the end part is parsed with net.ParseIP. If invalid, 'parser_invalid_end_ip' is returned with the offending string. It means the right side of the '-' range is not a parseable IP address.
Source
Thrown at common/parsers/parsers.go:363
}
startIPStr := strings.TrimSpace(parts[0])
endIPStr := strings.TrimSpace(parts[1])
startIP := net.ParseIP(startIPStr)
if startIP == nil {
return nil, fmt.Errorf("%s", i18n.Tr("parser_invalid_start_ip", startIPStr))
}
// 处理简写格式 (如: 192.168.1.1-100)
if len(endIPStr) < 4 || !strings.Contains(endIPStr, ".") {
return parseIPShortRange(startIPStr, endIPStr)
}
// 处理完整格式 (如: 192.168.1.1-192.168.1.100)
endIP := net.ParseIP(endIPStr)
if endIP == nil {
return nil, fmt.Errorf("%s", i18n.Tr("parser_invalid_end_ip", endIPStr))
}
return parseIPFullRange(startIP, endIP)
}
// parseIPShortRange 解析短格式IP范围
func parseIPShortRange(startIPStr, endSuffix string) ([]string, error) {
endNum, err := strconv.Atoi(endSuffix)
if err != nil || endNum > 255 {
return nil, fmt.Errorf("%s", i18n.Tr("parser_invalid_ip_end_val", endSuffix))
}
ipParts := strings.Split(startIPStr, ".")
if len(ipParts) != 4 {
return nil, fmt.Errorf("%s", i18n.Tr("parser_invalid_ip_fmt", startIPStr))
}
prefixIP := strings.Join(ipParts[0:3], ".")View on GitHub (pinned to 95cc12e753)
Solutions
- Write the end address as a full dotted-quad IPv4, e.g. 192.168.1.1-192.168.1.254
- Use shorthand form 192.168.1.1-100 if only the last octet varies (and end is short/undotted)
- Pre-validate with net.ParseIP(parts[1]) != nil before calling ParseIP
Example fix
// before
ParseIP("192.168.1.1-192.168.1", "")
// after
ParseIP("192.168.1.1-192.168.1.254", "") Defensive patterns
Strategy: validation
Validate before calling
func validEndIP(rangeStr string) bool {
parts := strings.Split(rangeStr, "-")
return len(parts) == 2 && net.ParseIP(strings.TrimSpace(parts[1])) != nil
} Try / catch
if !validEndIP(rangeStr) {
return fmt.Errorf("end of %q is not an IP", rangeStr)
}
_, err := parsers.ParseIP(rangeStr, "") Prevention
- Write the end address as a full dotted-quad IPv4
- Use numeric shorthand (e.g. .1.1-100) only for single-octet variation
- Verify variable substitution in scripts that build ranges
When it happens
Trigger: parseIPRangeString receiving ranges like '192.168.1.1-192.168.1' or '192.168.1.1-.100' where the end token fails net.ParseIP (and is long enough / dotted enough to skip the shorthand path).
Common situations: Truncated end addresses in hand-written target lists, copy-paste errors dropping an octet, or scripts substituting variables that resolve to empty/malformed ends.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- parser_ip_range_failed: %w
- parser_invalid_start_ip
- parser_cidr_failed: %w
- parser_invalid_ip_range_fmt
- parser_ip_range_failed: %w
AI-assisted analysis of shadow1ng/fscan@95cc12e753 (2026-09-06).
Data as JSON: /api/errors/7611e01432230c1a.
Report an issue: GitHub.