3x-ui/util/sys/sys_windows.go
civisrom b7c471e8f2 new file: xray/log_writer.go
new file:   xray/process.go
	new file:   xray/traffic.go
2025-02-04 14:38:53 +03:00

30 lines
492 B
Go

//go:build windows
// +build windows
package sys
import (
"errors"
"github.com/shirou/gopsutil/v4/net"
)
func GetConnectionCount(proto string) (int, error) {
if proto != "tcp" && proto != "udp" {
return 0, errors.New("invalid protocol")
}
stats, err := net.Connections(proto)
if err != nil {
return 0, err
}
return len(stats), nil
}
func GetTCPCount() (int, error) {
return GetConnectionCount("tcp")
}
func GetUDPCount() (int, error) {
return GetConnectionCount("udp")
}