{"record":{"id":"35c28f1b5c2296f2","repo":"XTLS/Xray-core","slug":"unknown-network-type","errorCode":null,"errorMessage":"unknown network type: ","messagePattern":"unknown network type: ","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/mux/frame.go","lineNumber":163,"sourceCode":"\t\tTargetNetwork(b.Byte(4)) == TargetNetworkUDP) { // MUST check the flag first\n\t\tif b.Len() < 8 {\n\t\t\treturn errors.New(\"insufficient buffer: \", b.Len())\n\t\t}\n\t\tnetwork := TargetNetwork(b.Byte(4))\n\t\tb.Advance(5)\n\n\t\taddr, port, err := addrParser.ReadAddressPort(nil, b)\n\t\tif err != nil {\n\t\t\treturn errors.New(\"failed to parse address and port\").Base(err)\n\t\t}\n\n\t\tswitch network {\n\t\tcase TargetNetworkTCP:\n\t\t\tf.Target = net.TCPDestination(addr, port)\n\t\tcase TargetNetworkUDP:\n\t\t\tf.Target = net.UDPDestination(addr, port)\n\t\tdefault:\n\t\t\treturn errors.New(\"unknown network type: \", network)\n\t\t}\n\t}\n\n\tif f.SessionStatus == SessionStatusNew && readSourceAndLocal {\n\t\tf.Inbound = &session.Inbound{}\n\n\t\tif b.Len() == 0 {\n\t\t\treturn nil // for heartbeat, etc.\n\t\t}\n\t\tnetwork := TargetNetwork(b.Byte(0))\n\t\tif network == 0 {\n\t\t\treturn nil // may be padding\n\t\t}\n\t\tb.Advance(1)\n\t\taddr, port, err := addrParser.ReadAddressPort(nil, b)\n\t\tif err != nil {\n\t\t\treturn errors.New(\"reading source: failed to parse address and port\").Base(err)\n\t\t}","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/common/mux/frame.go#L145-L181","documentation":"After successfully parsing an address in FrameMetadata.Unmarshal, the target network byte was neither TargetNetworkTCP nor TargetNetworkUDP. The address section is fine but the leading network-type byte holds an undefined value (anything other than the two defined flags), so the destination transport cannot be constructed.","triggerScenarios":"A frame's byte at offset 4 (target network) is a value like 0x02+ or garbage; happens with hand-rolled mux clients, stream corruption, or when a non-mux stream is parsed as frames.","commonSituations":"Custom client implementations that invent new network flags, protocol regressions between Xray versions, or bit corruption on the wire.","solutions":["Print/inspect the offending network byte (it is included in the message) to see if it is random garbage (corruption) or a fixed value (protocol mismatch).","Align client and server Xray-core versions.","If writing a custom mux client, emit only TargetNetworkTCP or TargetNetworkUDP in the target network byte.","Rule out stream corruption by testing the same link without TLS/Reality or over a known-clean network."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before unmarshalling (custom readers), sanity-check the network byte:\nif n := TargetNetwork(b.Byte(4)); n != TargetNetworkTCP && n != TargetNetworkUDP {\n    return fmt.Errorf(\"unsupported target network byte %d\", n)\n}","typeGuard":null,"tryCatchPattern":"if err := meta.Unmarshal(reader, rev); err != nil {\n    if strings.Contains(err.Error(), \"unknown network type\") { /* protocol mismatch: abort connection, log peer version */ }\n    return err\n}","preventionTips":["Custom clients must only emit defined TargetNetwork values.","Log the invalid byte value to distinguish corruption from version mismatch.","Keep mux protocol extensions coordinated across endpoints."],"tags":["mux","protocol","validation","xray"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}