shadow1ng/fscan · error

parser_ip_range_failed: %w

Error message

parser_ip_range_failed: %w

What it means

Inside parseHostString, tokens containing '-' (without ':', looking like IP ranges) are parsed by parseIPRangeString. Failure is wrapped with 'parser_ip_range_failed' plus the offending token, indicating an invalid IP range expression in the host list.

Source

Thrown at common/parsers/parsers.go:128

				return nil, err
			}
			hosts = append(hosts, cidrHosts...)
		case h == "10":
			cidrHosts, err := parseIPCIDR("10.0.0.0/8")
			if err != nil {
				return nil, err
			}
			hosts = append(hosts, cidrHosts...)
		case strings.Contains(h, "/"):
			cidrHosts, err := parseIPCIDR(h)
			if err != nil {
				return nil, fmt.Errorf(i18n.Tr("parser_cidr_failed", h)+": %w", err)
			}
			hosts = append(hosts, cidrHosts...)
		case strings.Contains(h, "-") && !strings.Contains(h, ":") && looksLikeIPRange(h):
			rangeHosts, err := parseIPRangeString(h)
			if err != nil {
				return nil, fmt.Errorf(i18n.Tr("parser_ip_range_failed", h)+": %w", err)
			}
			hosts = append(hosts, rangeHosts...)
		default:
			hosts = append(hosts, h)
		}
	}

	return hosts, nil
}

// =============================================================================
// 端口解析
// =============================================================================

// ParsePort 解析端口配置字符串为端口号列表
func ParsePort(ports string) []int {
	if ports == "" {
		return nil

View on GitHub (pinned to 95cc12e753)

Solutions

  1. Use a valid range with start <= end, e.g. 192.168.1.1-192.168.1.100
  2. For shorthand, keep the last octet numeric (192.168.1.1-100)
  3. Remove hyphenated strings that are not IP ranges (quote domain names elsewhere)
  4. Pre-validate both endpoints with net.ParseIP before calling ParseIP

Example fix

// before
ParseIP("192.168.1.100-192.168.1.10", "") // reversed
// after
ParseIP("192.168.1.10-192.168.1.100", "")
Defensive patterns

Strategy: validation

Validate before calling

func validIPRange(s string) bool {
	parts := strings.Split(s, "-")
	if len(parts) != 2 { return false }
	a, b := net.ParseIP(parts[0]), net.ParseIP(parts[1])
	return a != nil && b != nil && bytes.Compare(a, b) <= 0
}

Try / catch

hosts, err := parsers.ParseIP(host, "")
if err != nil {
	if strings.Contains(err.Error(), "parser_ip_range_failed") {
		log.Fatalf("fix range in %q: %v", host, err)
	}
	return err
}

Prevention

When it happens

Trigger: parseHostString sees a hyphenated token like '192.168.1.5-abc' or '192.168.1.100-192.168.1.1' that passes looksLikeIPRange but fails start/end IP parsing or produces an inverted range.

Common situations: Reversed ranges, ranges mixing hostnames and IPs, or domain names with hyphens misinterpreted when looksLikeIPRange misjudges them.

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


AI-assisted analysis of shadow1ng/fscan@95cc12e753 (2026-09-06). Data as JSON: /api/errors/12594194c13bc91b. Report an issue: GitHub.