{"record":{"id":"c6dbce0ff330a3ad","repo":"XTLS/Xray-core","slug":"trojan-fallbacks-invalid-proxy-protocol-version","errorCode":null,"errorMessage":"Trojan fallbacks: invalid PROXY protocol version, \"xver\" only accepts 0, 1, 2","messagePattern":"Trojan fallbacks: invalid PROXY protocol version, \"xver\" only accepts 0, 1, 2","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"infra/conf/trojan.go","lineNumber":200,"sourceCode":"\t\t\t\tif strings.HasPrefix(fb.Dest, \"@@\") && (runtime.GOOS == \"linux\" || runtime.GOOS == \"android\") {\n\t\t\t\t\tfullAddr := make([]byte, len(syscall.RawSockaddrUnix{}.Path)) // may need padding to work with haproxy\n\t\t\t\t\tcopy(fullAddr, fb.Dest[1:])\n\t\t\t\t\tfb.Dest = string(fullAddr)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif _, err := strconv.Atoi(fb.Dest); err == nil {\n\t\t\t\t\tfb.Dest = \"localhost:\" + fb.Dest\n\t\t\t\t}\n\t\t\t\tif _, _, err := net.SplitHostPort(fb.Dest); err == nil {\n\t\t\t\t\tfb.Type = \"tcp\"\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif fb.Type == \"\" {\n\t\t\treturn nil, errors.New(`Trojan fallbacks: please fill in a valid value for every \"dest\"`)\n\t\t}\n\t\tif fb.Xver > 2 {\n\t\t\treturn nil, errors.New(`Trojan fallbacks: invalid PROXY protocol version, \"xver\" only accepts 0, 1, 2`)\n\t\t}\n\t}\n\n\treturn config, nil\n}\n","sourceCodeStart":182,"sourceCodeEnd":206,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/infra/conf/trojan.go#L182-L206","documentation":"Thrown when a Trojan fallback's 'xver' (PROXY protocol version) is greater than 2. Only 0 (off), 1 (v1 text) and 2 (v2 binary) exist; the config check rejects anything larger, including the common mistake of copying the year or a bool.","triggerScenarios":"Setting \"xver\": 3 or higher in a Trojan inbound fallback entry.","commonSituations":"Misreading xver as a boolean/flag and writing a large number, or intending 'enabled' and typing an arbitrary value like 1/0 but fat-fingering 3+.","solutions":["Set \"xver\" to 0, 1, or 2 depending on whether the dest backend speaks PROXY protocol v1/v2","If the backend (e.g. nginx) has proxy_protocol off, use 0"],"exampleFix":"// before\n{ \"dest\": 80, \"xver\": 3 }\n// after\n{ \"dest\": 80, \"xver\": 1 }","handlingStrategy":"validation","validationCode":"xver := gjson.Get(fb.Raw, \"xver\").Int()\nif xver < 0 || xver > 2 {\n    return fmt.Errorf(\"fallback xver must be 0, 1 or 2, got %d\", xver)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat xver as a small enum (0/1/2), not a free-form number","Match xver to the backend's PROXY-protocol setting (nginx proxy_protocol on = 1 or 2)"],"tags":["config","trojan","fallback","proxy-protocol"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}