{"record":{"id":"83f8d343beef5551","repo":"XTLS/Xray-core","slug":"reading-source-unknown-network-type","errorCode":null,"errorMessage":"reading source: unknown network type: ","messagePattern":"reading source: unknown network type: ","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/mux/frame.go","lineNumber":188,"sourceCode":"\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}\n\t\tswitch network {\n\t\tcase TargetNetworkTCP:\n\t\t\tf.Inbound.Source = net.TCPDestination(addr, port)\n\t\tcase TargetNetworkUDP:\n\t\t\tf.Inbound.Source = net.UDPDestination(addr, port)\n\t\tdefault:\n\t\t\treturn errors.New(\"reading source: unknown network type: \", network)\n\t\t}\n\n\t\tif b.Len() == 0 {\n\t\t\treturn nil\n\t\t}\n\t\tnetwork = TargetNetwork(b.Byte(0))\n\t\tif network == 0 {\n\t\t\treturn nil\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 local: failed to parse address and port\").Base(err)\n\t\t}\n\t\tswitch network {\n\t\tcase TargetNetworkTCP:\n\t\t\tf.Inbound.Local = net.TCPDestination(addr, port)\n\t\tcase TargetNetworkUDP:","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/common/mux/frame.go#L170-L206","documentation":"In the inbound-source section of a mux frame, the network byte preceding the source address was neither TCP nor UDP. Address parsing succeeded but the transport type of the source destination cannot be determined, so unmarshalling aborts.","triggerScenarios":"readSourceAndLocal path parses a network byte that is non-zero (so it is not treated as padding) yet not one of the two defined TargetNetwork values; typical with hand-built frames or corrupted reverse-mux streams.","commonSituations":"Custom reverse-mux clients writing invalid network bytes, or version drift between client and server on the source-address layout.","solutions":["Log the offending network value to distinguish fixed invalid values (protocol bug) from random ones (corruption).","Pin matching Xray-core versions on both reverse-mux endpoints.","In custom clients, write only TargetNetworkTCP/TargetNetworkUDP or 0 for padding in source/local blocks.","Test over a clean transport to rule out middlebox interference."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// When building frames, always use a defined source network value:\nconst (\n    pad = 0 // padding / absent\n)\n// write pad instead of an invented network byte when source is omitted\nw.WriteByte(pad)","typeGuard":null,"tryCatchPattern":"if err := meta.Unmarshal(reader, true); err != nil {\n    if strings.Contains(err.Error(), \"reading source: unknown network type\") {\n        // peer encodes source blocks differently — abort, do not resync\n    }\n    return err\n}","preventionTips":["Only emit 0/TCP/UDP bytes in source-address slots.","Version-lock reverse-mux endpoints.","Add round-trip unit tests for frames that include source and local blocks."],"tags":["mux","reverse-proxy","validation","xray"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}