diff options
| author | mhsanaei <ho3ein.sanaei@gmail.com> | 2025-09-20 10:35:50 +0300 |
|---|---|---|
| committer | mhsanaei <ho3ein.sanaei@gmail.com> | 2025-09-20 10:35:50 +0300 |
| commit | 6ced549deaecb42b9bb93ea9efcb4c1bbaabe8a4 (patch) | |
| tree | 28d8d82530476cf607e4d05ca189ae05868711e6 /util/sys/sys_windows.go | |
| parent | f60682a6b7cb749fee403c84e2587c3ad7e7ced0 (diff) | |
docs: add comments for all functions
Diffstat (limited to 'util/sys/sys_windows.go')
| -rw-r--r-- | util/sys/sys_windows.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/util/sys/sys_windows.go b/util/sys/sys_windows.go index f3eae076..186fa4bb 100644 --- a/util/sys/sys_windows.go +++ b/util/sys/sys_windows.go @@ -12,6 +12,7 @@ import ( "github.com/shirou/gopsutil/v4/net" ) +// GetConnectionCount returns the number of active connections for the specified protocol ("tcp" or "udp"). func GetConnectionCount(proto string) (int, error) { if proto != "tcp" && proto != "udp" { return 0, errors.New("invalid protocol") @@ -24,10 +25,12 @@ func GetConnectionCount(proto string) (int, error) { return len(stats), nil } +// GetTCPCount returns the number of active TCP connections. func GetTCPCount() (int, error) { return GetConnectionCount("tcp") } +// GetUDPCount returns the number of active UDP connections. func GetUDPCount() (int, error) { return GetConnectionCount("udp") } @@ -50,6 +53,8 @@ type filetime struct { HighDateTime uint32 } +// ftToUint64 converts a Windows FILETIME-like struct to a uint64 for +// arithmetic and delta calculations used by CPUPercentRaw. func ftToUint64(ft filetime) uint64 { return (uint64(ft.HighDateTime) << 32) | uint64(ft.LowDateTime) } |
