Skip to content

Commit f74e70a

Browse files
author
wintrmvte
committed
info() -> userinfo() for clarity
1 parent 755e93c commit f74e70a

File tree

2 files changed

+33
-29
lines changed

2 files changed

+33
-29
lines changed

os_linux.go

+2-14
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,14 @@ import (
99
"os"
1010
"github.com/mitchellh/go-ps"
1111
)
12-
func info() string {
12+
13+
func userinfo() string {
1314
user, err := cmdOut("whoami")
1415
if err != nil {
1516
return "N/A"
1617
} else {
1718
return user
1819
}
19-
20-
// o, err := cmdOut("ip r")
21-
// if err != nil {
22-
// ap_ip = "N/A" // (1)
23-
// }
24-
// entries := strings.Split(o, "\n")
25-
// for e := range entries {
26-
// entry := entries[e]
27-
// if strings.Contains(entry, "default via") {
28-
// ap_ip = strings.Split(o, "")[2] // (1)
29-
// }
30-
// }
31-
3220
}
3321

3422
func killProcByPID(pid int) error {

os_windows.go

+31-15
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"os"
77
"golang.org/x/sys/windows"
8+
"strings"
89
ps "github.com/mitchellh/go-ps"
910
)
1011

@@ -29,26 +30,12 @@ func isRoot() bool {
2930
return root
3031
}
3132

32-
func info() string {
33+
func userinfo() string {
3334
user, err := cmdOut("query user")
3435
if err != nil {
3536
user = "N/A"
3637
}
3738

38-
// o, err := cmdOut("ipconfig")
39-
// if err != nil {
40-
// ap_ip = "N/A" // (1)
41-
// }
42-
43-
// entries := strings.Split(o, "\n")
44-
45-
// for e := range entries {
46-
// entry := entries[e]
47-
// if strings.Contains(entry, "Default") {
48-
// ap_ip = strings.Split(entry, ":")[1] // (1)
49-
// }
50-
// }
51-
5239
return user
5340
}
5441

@@ -121,3 +108,32 @@ func disks() ([]string, error) {
121108
}
122109
return found_drives, nil
123110
}
111+
112+
func users() ([]string, error) {
113+
clear := []string{}
114+
o, err := cmdOut("net user")
115+
if err != nil {
116+
return nil, err
117+
}
118+
119+
lines := strings.Split(o, "\n")
120+
121+
for l := range lines {
122+
line := lines[l]
123+
if !ContainsAny(line, []string{"accounts for", "------", "completed"}) {
124+
clear = append(clear, line)
125+
}
126+
}
127+
128+
return clear, nil
129+
// return strings.Fields(strings.Join(clear, " ")), nil
130+
// usrs := []string{}
131+
// users, err := wapi.ListLoggedInUsers()
132+
// if err != nil {
133+
// return nil, err
134+
// }
135+
// for _, u := range(users){
136+
// usrs = append(usrs, u.FullUser())
137+
// }
138+
// return usrs, nil
139+
}

0 commit comments

Comments
 (0)