-
Notifications
You must be signed in to change notification settings - Fork 8
/
system.go
50 lines (38 loc) · 1.05 KB
/
system.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"os/exec"
"strings"
)
type Ubus func(arg string) ([]byte, error)
var UbusCall = Ubus(func(arg string) ([]byte, error) {
args := strings.Split(arg, " ")
args = append([]string{"-S", "call"}, args...)
return exec.Command("ubus", args...).Output()
})
func (u Ubus) Info() ([]byte, error) {
return u("system info")
}
func (u Ubus) BoardInfo() ([]byte, error) {
return u("system board")
}
func (u Ubus) WanStatus() ([]byte, error) {
return u("network.interface.wan status")
}
func (u Ubus) LanStatus() ([]byte, error) {
return u("network.interface.lan status")
}
func (u Ubus) WirelessStatus() ([]byte, error) {
return u("network.wireless status")
}
func (u Ubus) ServiceList() ([]byte, error) {
return u("service list")
}
func (u Ubus) InterfacesList() ([]byte, error) {
return u("network.device status")
}
func (u Ubus) NetworkConfig() ([]byte, error) {
return u("uci get {\"config\":\"network\"}")
}
func (u Ubus) WlanClients() ([]byte, error) {
return u("hostapd.wlan0 get_clients")
}