XTLS/Xray-core · error
Invalid PacketsFrom
Error message
Invalid PacketsFrom
What it means
Thrown while parsing the freedom outbound's fragment 'packets' setting when it is neither "tlshello" nor empty: the value is treated as a numeric range string (e.g. "1-3") and ParseRangeString fails. The underlying parse error is chained via .Base(err), so the full message shows why the range is malformed.
Source
Thrown at infra/conf/freedom.go:109
}
if c.Fragment != nil {
config.Fragment = new(freedom.Fragment)
switch strings.ToLower(c.Fragment.Packets) {
case "tlshello":
// TLS Hello Fragmentation (into multiple handshake messages)
config.Fragment.PacketsFrom = 0
config.Fragment.PacketsTo = 1
case "":
// TCP Segmentation (all packets)
config.Fragment.PacketsFrom = 0
config.Fragment.PacketsTo = 0
default:
// TCP Segmentation (range)
from, to, err := ParseRangeString(c.Fragment.Packets)
if err != nil {
return nil, errors.New("Invalid PacketsFrom").Base(err)
}
config.Fragment.PacketsFrom = uint64(from)
config.Fragment.PacketsTo = uint64(to)
if config.Fragment.PacketsFrom == 0 {
return nil, errors.New("PacketsFrom can't be 0")
}
}
{
if c.Fragment.Length == nil {
return nil, errors.New("Length can't be empty")
}
config.Fragment.LengthMin = uint64(c.Fragment.Length.From)
config.Fragment.LengthMax = uint64(c.Fragment.Length.To)
if config.Fragment.LengthMin == 0 {
return nil, errors.New("LengthMin can't be 0")
}
}View on GitHub (pinned to 7d214f8b09)
Solutions
- Write the packets range as "from-to", e.g. "1-3" for TCP segmentation of packets 1 through 3.
- Use "tlshello" for TLS-hello fragmentation or omit/empty for all packets.
- Read the chained base error to see the exact parse failure reason.
Example fix
// before "packets": "1:3" // after "packets": "1-3"
Defensive patterns
Strategy: validation
Validate before calling
if p := fragment.Packets; p != "" && p != "tlshello" {
if _, _, err := ParseRangeString(p); err != nil {
return fmt.Errorf("fragment.packets %q must be 'tlshello', '', or 'N-M': %w", p, err)
}
} Prevention
- Use dash-separated ranges ("1-3"), not colon-separated.
- Reserve "tlshello" and "" for their special meanings.
- Lint fragment sub-fields together in one check.
When it happens
Trigger: "fragment": {"packets": "1:3"} (colon instead of dash), "packets": "1-", "packets": "abc" — any value that ParseRangeString cannot parse as a from-to range. The "tlshello" and "" special cases bypass this path.
Common situations: Using wrong range separators; copying fragment examples from other projects that use 'x:y' notation; stray whitespace or unicode dashes.
Related errors
- unsupported domain strategy: {}
- PacketsFrom can't be 0
- Length can't be empty
- LengthMin can't be 0
- Interval can't be empty
AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15).
Data as JSON: /api/errors/8b6ea7861890f4cb.
Report an issue: GitHub.