{"record":{"id":"85a799f4ab228709","repo":"XTLS/Xray-core","slug":"not-trojan-protocol","errorCode":null,"errorMessage":"not trojan protocol","messagePattern":"not trojan protocol","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/trojan/server.go","lineNumber":178,"sourceCode":"\tif err != nil {\n\t\treturn errors.New(\"failed to read first request\").Base(err)\n\t}\n\terrors.LogInfo(ctx, \"firstLen = \", firstLen)\n\n\tbufferedReader := &buf.BufferedReader{\n\t\tReader: buf.NewReader(conn),\n\t\tBuffer: buf.MultiBuffer{first},\n\t}\n\n\tvar user *protocol.MemoryUser\n\n\tnapfb := s.fallbacks\n\tisfb := napfb != nil\n\n\tshouldFallback := false\n\tif firstLen < 58 || first.Byte(56) != '\\r' {\n\t\t// invalid protocol\n\t\terr = errors.New(\"not trojan protocol\")\n\t\tlog.Record(&log.AccessMessage{\n\t\t\tFrom:   conn.RemoteAddr(),\n\t\t\tTo:     \"\",\n\t\t\tStatus: log.AccessRejected,\n\t\t\tReason: err,\n\t\t})\n\n\t\tshouldFallback = true\n\t} else {\n\t\tuser = s.validator.Get(hexString(first.BytesTo(56)))\n\t\tif user == nil {\n\t\t\t// invalid user, let's fallback\n\t\t\terr = errors.New(\"not a valid user\")\n\t\t\tlog.Record(&log.AccessMessage{\n\t\t\t\tFrom:   conn.RemoteAddr(),\n\t\t\t\tTo:     \"\",\n\t\t\t\tStatus: log.AccessRejected,\n\t\t\t\tReason: err,","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/proxy/trojan/server.go#L160-L196","documentation":"First-packet sniffing guard: the initial buffer is shorter than 58 bytes or byte 56 is not CR, so the request cannot be a Trojan header; it is recorded as rejected and routed to fallback if configured.","triggerScenarios":"Thrown at proxy/trojan/server.go:178 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Point non-Trojan traffic at the fallback destinations configured on the inbound","If Trojan was expected, check the client and any TLS termination in front"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","contentChangedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}