XTLS/Xray-core · error
syntax error
Error message
syntax error
What it means
parseGeoIPRule splits the rule on ':' via strings.Cut; if there is no ':' at all, ok is false and this error is raised. It means the caller routed a rule into the GeoIP branch (prefix > 0 or ext:/geosite-style handling) but the string lacks the required FILE:CODE shape.
Source
Thrown at common/geodata/rule_parser.go:62
ipRules = append(ipRules, &IPRule{Value: rule})
}
return ipRules, nil
}
func cutReversePrefix(s string) (string, bool) {
reverse := false
for strings.HasPrefix(s, "!") {
s = s[1:]
reverse = !reverse
}
return s, reverse
}
func parseGeoIPRule(rule string, reverse bool) (*IPRule_Geoip, error) {
file, code, ok := strings.Cut(rule, ":")
if !ok {
return nil, errors.New("syntax error")
}
if file == "" {
return nil, errors.New("empty file")
}
code, codeReverse := cutReversePrefix(code)
reverse = reverse != codeReverse
if code == "" {
return nil, errors.New("empty code")
}
code = strings.ToUpper(code)
if err := checkFile(file, code); err != nil {
return nil, err
}
return &IPRule_Geoip{View on GitHub (pinned to 7d214f8b09)
Solutions
- Rewrite the rule as FILE:CODE, e.g. "ext:geoip.dat:cn" or "geoip:cn".
- For plain CIDR/IP rules (no file), drop the prefix so parseCustomIPRule handles them.
Example fix
// before "ip": ["ext:geoip.dat"] // after "ip": ["ext:geoip.dat:cn"]
Defensive patterns
Strategy: validation
Validate before calling
if strings.HasPrefix(r, "ext:") || strings.HasPrefix(r, "geoip") {
if !strings.Contains(r, ":") || strings.HasSuffix(r, ":") { return fmt.Errorf("rule %q must be FILE:CODE", r) }
} Prevention
- Template geoip rules as "geoip:CODE" and ext rules as "ext:FILE.dat:CODE" so the colon is never omitted.
When it happens
Trigger: A rule string beginning with a recognized prefix but containing no colon, e.g. "ext:geoip.dat" is fine but a custom path like "ext" or "geoip-only-cn" (no ':') reaching this parser.
Common situations: Forgetting the country code segment: "ext:geoip.dat" instead of "ext:geoip.dat:cn"; omitting code after "geosite:" style aliasing when the alias is missing.
Related errors
AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15).
Data as JSON: /api/errors/218263fd45ba7e91.
Report an issue: GitHub.