{"record":{"id":"7022fc90332c4848","repo":"netchx/netch","slug":"invalid-tcp-type-server-faketype","errorCode":null,"errorMessage":"Invalid tcp type {server.FakeType}","messagePattern":"Invalid tcp type (.+?)","errorType":"exception","errorClass":"MessageException","httpStatus":null,"severity":"error","filePath":"Netch/Servers/V2ray/V2rayConfigUtils.cs","lineNumber":346,"sourceCode":"            case \"tcp\":\n\n                streamSettings.tcpSettings = new TcpSettings\n                {\n                    header = new\n                    {\n                        type = server.FakeType,\n                        request = server.FakeType switch\n                        {\n                            \"none\" => null,\n                            \"http\" => new\n                            {\n                                path = server.Path.SplitOrDefault(),\n                                headers = new\n                                {\n                                    Host = server.Host.SplitOrDefault()\n                                }\n                            },\n                            _ => throw new MessageException($\"Invalid tcp type {server.FakeType}\")\n                        }\n                    }\n                };\n\n                break;\n            case \"ws\":\n\n                streamSettings.wsSettings = new WsSettings\n                {\n                    path = server.Path.ValueOrDefault(),\n                    headers = new\n                    {\n                        Host = server.Host.ValueOrDefault()\n                    }\n                };\n\n                break;\n            case \"kcp\":","sourceCodeStart":328,"sourceCodeEnd":364,"githubUrl":"https://github.com/netchx/netch/blob/9d99eb1c5a2acbf2a34f2600f94242601019a300/Netch/Servers/V2ray/V2rayConfigUtils.cs#L328-L364","documentation":"When building V2Ray StreamSettings for a VMess/VLESS server whose TransferProtocol is 'tcp', the header obfuscation FakeType is only allowed to be 'none' or 'http'. The switch over server.FakeType handles those two cases and throws on the wildcard for anything else. The other entries in VMessGlobal.FakeTypes (srtp, utp, wechat-video, dtls, wireguard, gun, multi) are valid only for kcp/quic/grpc transports, not tcp.","triggerScenarios":"A VMess/VLESS server configured with TransferProtocol='tcp' and a FakeType that is not none/http (e.g. srtp, http copied from a kcp config). Importing a vmess:// link whose headerType field is incompatible with net=tcp; manually editing the server JSON to an invalid combination.","commonSituations":"Copy-pasting kcp obfuscation settings onto a tcp server; a malformed share link with headerType set for the wrong transport; an older client exporting headerType even when net is tcp; user conflating FakeType semantics across transports.","solutions":["Set FakeType to 'none' or 'http' when TransferProtocol is tcp.","If you need srtp/utp/wechat-video/dtls/wireguard obfuscation, switch TransferProtocol to kcp; for gun/multi use grpc.","Re-import the vmess:// or vless:// link from a trusted source.","Validate the (TransferProtocol, FakeType) pair in the server editor before saving the server."],"exampleFix":"// before\nrequest = server.FakeType switch\n{\n    \"none\" => null,\n    \"http\"  => new { path = server.Path.SplitOrDefault(), headers = new { Host = server.Host.SplitOrDefault() } },\n    _       => throw new MessageException($\"Invalid tcp type {server.FakeType}\")\n};\n// after - treat an unknown tcp FakeType as none instead of throwing\nrequest = server.FakeType switch\n{\n    \"none\" => null,\n    \"http\"  => new { path = server.Path.SplitOrDefault(), headers = new { Host = server.Host.SplitOrDefault() } },\n    _       => null\n};","handlingStrategy":"validation","validationCode":"// Validate before building V2Ray config\nstatic readonly HashSet<string> TcpFakeTypes = new() { \"none\", \"http\" };\nif (server.TransferProtocol == \"tcp\" && !TcpFakeTypes.Contains(server.FakeType))\n    throw new MessageException($\"tcp only supports FakeType none/http, got '{server.FakeType}'\");","typeGuard":"bool IsValidTcpFakeType(string fakeType) => fakeType is \"none\" or \"http\";\nbool IsValidPair(string protocol, string fakeType) => protocol switch\n{\n    \"tcp\"  => fakeType is \"none\" or \"http\",\n    \"kcp\"  => fakeType is \"none\" or \"srtp\" or \"utp\" or \"wechat-video\" or \"dtls\" or \"wireguard\",\n    \"grpc\" => fakeType is \"gun\" or \"multi\",\n    _      => true\n};","tryCatchPattern":"try { streamSettings = BuildStreamSettings(server); }\ncatch (MessageException ex) when (ex.Message.StartsWith(\"Invalid tcp type\"))\n{\n    MessageBoxX.Show(\"This server's header type is invalid for tcp. Set it to none or http.\", LogLevel.ERROR);\n}","preventionTips":["Constrain the FakeType combo box options based on the selected TransferProtocol in the server editor.","Reject mismatched (net, headerType) pairs at import time in ParseUri.","Keep the canonical allowed-pairs table (VMessGlobal.TransferProtocols / FakeTypes) as the single source of truth."],"tags":["v2ray","vmess","vless","stream-settings","config","validation"],"backgroundTag":null,"analyzedSha":"9d99eb1c5a2acbf2a34f2600f94242601019a300","analyzedAt":"2026-08-13T14:12:19.105Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}