Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'util/sys/sys_linux.go')
-rw-r--r--util/sys/sys_linux.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/util/sys/sys_linux.go b/util/sys/sys_linux.go
index 8a494d62..23483b57 100644
--- a/util/sys/sys_linux.go
+++ b/util/sys/sys_linux.go
@@ -45,6 +45,8 @@ func getLinesNum(filename string) (int, error) {
return sum, nil
}
+// GetTCPCount returns the number of active TCP connections by reading
+// /proc/net/tcp and /proc/net/tcp6 when available.
func GetTCPCount() (int, error) {
root := HostProc()
@@ -75,6 +77,8 @@ func GetUDPCount() (int, error) {
return udp4 + udp6, nil
}
+// safeGetLinesNum returns 0 if the file does not exist, otherwise forwards
+// to getLinesNum to count the number of lines.
func safeGetLinesNum(path string) (int, error) {
if _, err := os.Stat(path); os.IsNotExist(err) {
return 0, nil