Add net.online to diag sys command
Currently there was no sure way to check if node is in online or offline mode. License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
Jakub Sztandera committed
Jun 18, 2016 at 12:39 UTC
e67a21ed6a6558c1965c2973d6a0e066a7db66bc
1 file changed
+8
-2
core/commands/sysdiag.go
+8
-2
@@ -44,8 +44,13 @@ Prints out information about your computer to aid in easier debugging.
44
res.SetError(err, cmds.ErrNormal)
45
return
46
}
47
+ node, err := req.InvocContext().GetNode()
48
+ if err != nil {
49
+ res.SetError(err, cmds.ErrNormal)
50
+ return
51
+ }
52
48
- err = netInfo(info)
53
+ err = netInfo(node.OnlineMode(), info)
54
if err != nil {
55
res.SetError(err, cmds.ErrNormal)
56
return
@@ -117,7 +122,7 @@ func memInfo(out map[string]interface{}) error {
122
return nil
123
}
124
120
-func netInfo(out map[string]interface{}) error {
125
+func netInfo(online bool, out map[string]interface{}) error {
126
n := make(map[string]interface{})
127
addrs, err := manet.InterfaceMultiaddrs()
128
if err != nil {
@@ -130,6 +135,7 @@ func netInfo(out map[string]interface{}) error {
135
}
136
137
n["interface_addresses"] = straddrs
138
+ n["online"] = online
139
out["net"] = n
140
return nil
141
}