134 Commits (v3.22.1)

Author SHA1 Message Date
Ville Skyttä 1e56c6f421 Spelling and grammar fixes
Lomanic d826e14e27 [net][linux] Fix #1198 "f.ReadDir undefined" on Go 1.15 by redefining a custom readDir according to go version
Using os.File.Readdir pre Go 1.16 and os.File.ReadDir post Go 1.16
mmorel-35 1e6b445a8a gofumpt
mmorel-35 eb5f6203d8 gofmt
Matthieu MOREL b673968d5d
enable errorlint linter
shirou d2e27c1712 fix dependabot v2 deletion.
shirou 0969c9436b delete v2 directory, move v3 to top #1078
shirou 3d97fc18f4 add check if it runs on CI
shirou c6bd05a3e9 relax net/NetIOCountersAll test.
It often fails in CI.
MashaSamoylova 7631bb0e5e Fix lsof args for udp4 in unix
shirou 34412e0b7f [net] relax NetIOCounterAll test
shirou 6286bea32a
Merge pull request #989 from Lomanic/issue734tests
[ci] Implement automatic tests on GH Actions on linux, windows and darwin
Lomanic 64e16cc8c3 [net][darwin] Fix tests with mismatched types
Lomanic 7f0ba43398 [net][darwin][freebsd] Fix tests with func not returning common.ErrNotImplementedError
MashaSamoylova 860f332c22 Fix getting udp6 ports
shirou f377a07e5a fix test and openbsd errors.
Sergey Vinogradov 8ff2ab3187 Add "vet" target to the Makefile
Making the "vet" target will run "go vet ./..." for each supported
GOOS.

Also, some of the warnings produced by go 1.15 vet were mitigated.
Lomanic 4cfc60d68b
Merge pull request #928 from Lomanic/skip-tests-when-not-implemented
Lomanic e1925b853e
Merge pull request #935 from Lomanic/issue900
[linux] Fix #900, skip or fix failing tests in docker
Lomanic 1b3e0c6643 [linux] Fix #900, skip or fix failing tests in docker
TestGetProcInodesAll: create a server so there are some opened inodes
TestUsers: skip if Users is empty, because of an empty /var/run/utmp
Test_Process_Groups: skip if Groups is empty
TestConnectionsMax: skip on CI, not only CircleCI
Lomanic ab084b525c [net] Skip tests on non-implemented platforms #446
Disconnect3d 5c1a9e709d net_linux.go: decode port as 16-bit uint
Changes the port parsing from `/proc/net/*` files records from parsing them as 64-bit integers to parse them as 16-bit unsigned integers.

While this is mostly a cosmetic change, it will also make so that the code fails faster in case the entry is malformed (for whatever reason).

Note that the returned value is still casted to uint32 when an  `Addr` object is created.
It seems to me that the `Addr.port` field should be changed to `uint16` but maybe some other APIs/systems wants it to be `uint32` and also changing it there may require changes in users code if they update. This being said I am not changing that field's type.
gtosh4 936d3b27f1
Don't ignore context for io counters
shirou 53cec6b37e
Merge pull request #839 from tklauser/move-parse-funcs
net: move parseNetLine and parseNetAddr to net_unix.go
Tobias Klauser 22d8ee41e5 net: move parseNetLine and parseNetAddr to net_unix.go
These funcs are only used in net_unix.go which is only compiled for
darwin and freebsd.
Clément Chigot 77ff16c081 net: add AIX support
Brian C. Williams f00df5cffe Add WithoutUids funcs
Snow Fox 018950cf06
Merge pull request #2 from shirou/master
merge master
litong 1f9466536e Add ifIndex support
litong 7ffe40e0db Add ifIndex support
Lomanic 6a8ab0308e [net][linux] Go fmt net/net_linux.go
chi-chi weng 809306b78a
Fix the net.ConnectionsMax BUG
`connectionsList, err := net.ConnectionsMax("tcp4", 1000)`
when you run net.ConnectionsMax,you will find some proc is not equal with the `netstat -lptn`
Lomanic 658804ae70
Merge pull request #697 from Lomanic/issue693
[net][windows] Fix #693 use MIB_IF_ROW2/GetIfEntry2 to get real uint64 values from win32 API
Lomanic 3fb9243fc2 [net][windows] Fix #693 use MIB_IF_ROW2/GetIfEntry2 to get real uint64 values from win32 API
Curtis Mattoon 648bf4eebc Adds ConntrackStats to get conntrack summary stats
Segflow 86c7289ccc Fix: use filename in exec.LookPath instead of full path
exec.LookPath searches for the file in the $PATH, which mean giving it an absolute path is against it's own purposes.
mingrammer 017c9f9cbc Fix typos
Joe Stringer f87d9813da [net][linux] Support socket tables in nested namespaces
Signed-off-by: Joe Stringer <joe@cilium.io>
Iskander Sharipov 3684fce88a net: use multi-value case clause instead of fallthrough
Found using https://go-critic.github.io/overview#emptyFallthrough-ref
Lomanic eb1f1ab16f
Merge pull request #549 from pytimer/win_net
[net] Implements windows net package Connections and ConnectionsPid
Lomanic ef54649286 [windows] Use windows.NewLazySystemDLL to (possibly) prevent DLL hijacking
Might be useless because of https://docs.microsoft.com/en-us/windows/desktop/dlls/dynamic-link-library-search-order#search-order-for-desktop-applications
but better be safe than sorry.

Ref: https://github.com/shirou/gopsutil/issues/570#issuecomment-413951653
pytimer 0ffcfc901f [net][windows] Remove exported types and convert ALL_CAPS to mixedCaps
pytimer 1c2cebbbc4 [net] Implements windows net package function Connections and ConnectionsPid
Kamil Dziedzic b76d065dff
PMM-2643: Support listing unix sockets in ConnectionsPid and ConnectionsPidWithContext.
Signed-off-by: Kamil Dziedzic <arvenil@klecza.pl>
Michal Rostecki 9d003ad2e1 net: Check for error object
shirou 145dca90f7 change to use CommandContext.
Laurie Clark-Michalek 413cb32b6c Use static initialisation for invoke instances, instead of init funcs
The order of init function execution is dependant on the order that the
source files are passed to the compiler. This causes issues when
building under other build systems, such as bazel or buck, as they are
not guarenteed to maintain the same file order as the default go tool.
shirou 4c73494c78 Add WithContext functions.
Daniel Nelson 6abd227e48
[net] linux: skip if not exist error on getProcInodesAll
Marco Pfatschbacher df6462b50e Fix PR comments made by shirou