v2rayA/v2rayA · info
netstat: operating system is not supported
Error message
netstat: operating system is not supported
What it means
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.
Source
Thrown at service/common/netTools/netstat/netstat.go:9
package netstat
import (
"fmt"
"net"
"sync"
)
var ErrorNotSupportOSErr = fmt.Errorf("netstat: operating system is not supported")
const (
Established SkState = 0x01
SynSent = 0x02
SynRecv = 0x03
FinWait1 = 0x04
FinWait2 = 0x05
TimeWait = 0x06
Close = 0x07
CloseWait = 0x08
LastAck = 0x09
Listen = 0x0a
Closing = 0x0b
)
var skStates = [...]string{
"UNKNOWN",
"ESTABLISHED",View on GitHub (pinned to 71e5442fc5)
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
Example fix
// before
occ, err := netstat.IsProcessListenPort(8080) // on windows -> ErrorNotSupportOSErr
// after
if errors.Is(err, netstat.ErrorNotSupportOSErr) {
// fallback: skip process lookup
return nil
} Defensive patterns
Strategy: fallback
Validate before calling
if runtime.GOOS != "linux" && runtime.GOOS != "darwin" {
// netstat package will return ErrorNotSupportOSErr
return fmt.Errorf("port-process lookup unsupported on %s", runtime.GOOS)
} Type guard
func netstatSupported(goos string) bool {
return goos == "linux" || goos == "darwin"
} Try / catch
proc, err := sock.Process()
if errors.Is(err, netstat.ErrorNotSupportOSErr) {
proc = nil // degrade gracefully
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- parseIPv4: %w
- parseIPv6: %w
- netstat: not enough fields: %v
- parseAddr: Bad formatted string
- parseAddr: %w
AI-assisted analysis of v2rayA/v2rayA@71e5442fc5 (2026-09-05).
Data as JSON: /api/errors/cdd396d0427c4226.
Report an issue: GitHub.