{"record":{"id":"cdd396d0427c4226","repo":"v2rayA/v2rayA","slug":"netstat-operating-system-is-not-supported","errorCode":null,"errorMessage":"netstat: operating system is not supported","messagePattern":"netstat: operating system is not supported","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"service/common/netTools/netstat/netstat.go","lineNumber":9,"sourceCode":"package netstat\n\nimport (\n\t\"fmt\"\n\t\"net\"\n\t\"sync\"\n)\n\nvar ErrorNotSupportOSErr = fmt.Errorf(\"netstat: operating system is not supported\")\n\nconst (\n\tEstablished SkState = 0x01\n\tSynSent             = 0x02\n\tSynRecv             = 0x03\n\tFinWait1            = 0x04\n\tFinWait2            = 0x05\n\tTimeWait            = 0x06\n\tClose               = 0x07\n\tCloseWait           = 0x08\n\tLastAck             = 0x09\n\tListen              = 0x0a\n\tClosing             = 0x0b\n)\n\nvar skStates = [...]string{\n\t\"UNKNOWN\",\n\t\"ESTABLISHED\",","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/v2rayA/v2rayA/blob/71e5442fc548c05680ee55eae943e6c0afe9ac51/service/common/netTools/netstat/netstat.go#L1-L27","documentation":"ErrorNotSupportOSErr is the sentinel returned by all netstat functions (FillProcesses, Process, ToPortMap, IsProcessListenPort, PortOccupied) on platforms that have no netstat implementation. The package only implements real parsing for supported OSes (e.g. Linux via /proc); the netstat_other.go stub returns it everywhere else.","triggerScenarios":"Calling PortOccupied/ToPortMap/Process/FillProcesses on an OS without a build-tagged implementation (e.g. Windows, or any platform not covered by netstat_linux/netstat_darwin files).","commonSituations":"Cross-compiling or running v2rayA-derived code on Windows where netstat_other.go is compiled; embedding the netstat package in a non-Linux/non-macOS service.","solutions":["Run on a supported OS (Linux or macOS) so the real implementation is compiled in","Check build tags: ensure GOOS is linux/darwin when building","Implement a netstat_<os>.go for your platform following the Socket/Process API","Guard port-occupancy logic at runtime and degrade gracefully when the sentinel is returned"],"exampleFix":"// before\nocc, err := netstat.IsProcessListenPort(8080) // on windows -> ErrorNotSupportOSErr\n// after\nif errors.Is(err, netstat.ErrorNotSupportOSErr) {\n    // fallback: skip process lookup\n    return nil\n}","handlingStrategy":"fallback","validationCode":"if runtime.GOOS != \"linux\" && runtime.GOOS != \"darwin\" {\n    // netstat package will return ErrorNotSupportOSErr\n    return fmt.Errorf(\"port-process lookup unsupported on %s\", runtime.GOOS)\n}","typeGuard":"func netstatSupported(goos string) bool {\n    return goos == \"linux\" || goos == \"darwin\"\n}","tryCatchPattern":"proc, err := sock.Process()\nif errors.Is(err, netstat.ErrorNotSupportOSErr) {\n    proc = nil // degrade gracefully\n}","preventionTips":["Gate netstat-dependent features on GOOS at startup","Provide a fallback port check (e.g. net.Listen probe) on unsupported OSes","Check build tags when adding new platform files"],"tags":["platform","netstat","unsupported-os"],"backgroundTag":"os-not-supported","analyzedSha":"71e5442fc548c05680ee55eae943e6c0afe9ac51","analyzedAt":"2026-09-05T20:04:37.459Z","contentChangedAt":"2026-09-05T20:04:37.459Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}