{"record":{"id":"299721d729fec1e9","repo":"XTLS/Xray-core","slug":"unknown-network-network","errorCode":null,"errorMessage":"unknown network: {network}","messagePattern":"unknown network: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/socks/server.go","lineNumber":93,"sourceCode":"\t}\n\n\tswitch network {\n\tcase net.Network_TCP:\n\t\tfirstbyte := make([]byte, 1)\n\t\tif n, err := conn.Read(firstbyte); n == 0 {\n\t\t\tif goerrors.Is(err, io.EOF) {\n\t\t\t\terrors.LogInfo(ctx, \"Connection closed immediately, likely health check connection\")\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\treturn errors.New(\"failed to read from connection\").Base(err)\n\t\t}\n\t\tif firstbyte[0] != 5 && firstbyte[0] != 4 { // Check if it is Socks5/4/4a\n\t\t\terrors.LogDebug(ctx, \"Not Socks request, try to parse as HTTP request\")\n\t\t\treturn s.httpServer.ProcessWithFirstbyte(ctx, network, conn, dispatcher, firstbyte...)\n\t\t}\n\t\treturn s.processTCP(ctx, conn, dispatcher, firstbyte)\n\tdefault:\n\t\treturn errors.New(\"unknown network: \", network)\n\t}\n}\n\nfunc (s *Server) processTCP(ctx context.Context, conn stat.Connection, dispatcher routing.Dispatcher, firstbyte []byte) error {\n\tplcy := s.policy()\n\tif err := conn.SetReadDeadline(time.Now().Add(plcy.Timeouts.Handshake)); err != nil {\n\t\terrors.LogInfoInner(ctx, err, \"failed to set deadline\")\n\t}\n\n\tinbound := session.InboundFromContext(ctx)\n\tif inbound == nil || !inbound.Gateway.IsValid() {\n\t\treturn errors.New(\"inbound gateway not specified\")\n\t}\n\n\tsvrSession := &ServerSession{\n\t\tconfig:       s.config,\n\t\taddress:      inbound.Gateway.Address,\n\t\tport:         inbound.Gateway.Port,","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/proxy/socks/server.go#L75-L111","documentation":"Thrown by the SOCKS inbound's Network() dispatcher when the connection network is not TCP. The inbound only implements the TCP branch (with UDP handled inside via UDP ASSOCIATE over TCP), so a UDP packet delivered directly to Network() hits the default case.","triggerScenarios":"The framework calls Process/Network with net.Network_UDP (or any non-TCP network) on this inbound — e.g. misconfigured listener binding the SOCKS inbound to a UDP socket, or an internal routing rewrite delivering UDP directly.","commonSituations":"Copying adoket/dokodemo style config where the inbound listens on UDP; a bug in a custom caller invoking Process with a UDP connection; version skew between core and a third-party launcher generating invalid inbound config.","solutions":["Ensure the socks inbound's streamSettings/listener only binds TCP (remove any UDP listen setting).","For raw UDP ingress use a dokodemo-door inbound with network UDP instead of socks.","If writing custom code that calls this handler, only pass net.Network_TCP connections.","Upgrade the launcher/panel generating the config to one that emits valid SOCKS inbound configs."],"exampleFix":"// before: trying to feed UDP straight into a socks inbound\n{ \"protocol\": \"socks\", \"port\": 1080, \"settings\": { \"udp\": true } }\n\n// after: socks over TCP; UDP arrives via UDP ASSOCIATE (or use dokodemo for raw UDP)\n{ \"protocol\": \"socks\", \"port\": 1080, \"settings\": { \"auth\": \"noauth\" } }","handlingStrategy":"validation","validationCode":"if network != net.Network_TCP {\n\treturn errors.New(\"socks inbound accepts TCP only; UDP arrives via UDP ASSOCIATE\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Bind SOCKS inbounds to TCP listeners only.","Use dokodemo-door for raw UDP ingress.","Validate generated config against the JSON schema before deploy."],"tags":["socks","inbound","network","config","dispatcher"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}