提交 e67a21ed 作者: Jakub Sztandera

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: 's avatarJakub Sztandera <kubuxu@protonmail.ch>
上级 2a3bba3a
...@@ -44,8 +44,13 @@ Prints out information about your computer to aid in easier debugging. ...@@ -44,8 +44,13 @@ Prints out information about your computer to aid in easier debugging.
res.SetError(err, cmds.ErrNormal) res.SetError(err, cmds.ErrNormal)
return return
} }
node, err := req.InvocContext().GetNode()
if err != nil {
res.SetError(err, cmds.ErrNormal)
return
}
err = netInfo(info) err = netInfo(node.OnlineMode(), info)
if err != nil { if err != nil {
res.SetError(err, cmds.ErrNormal) res.SetError(err, cmds.ErrNormal)
return return
...@@ -117,7 +122,7 @@ func memInfo(out map[string]interface{}) error { ...@@ -117,7 +122,7 @@ func memInfo(out map[string]interface{}) error {
return nil return nil
} }
func netInfo(out map[string]interface{}) error { func netInfo(online bool, out map[string]interface{}) error {
n := make(map[string]interface{}) n := make(map[string]interface{})
addrs, err := manet.InterfaceMultiaddrs() addrs, err := manet.InterfaceMultiaddrs()
if err != nil { if err != nil {
...@@ -130,6 +135,7 @@ func netInfo(out map[string]interface{}) error { ...@@ -130,6 +135,7 @@ func netInfo(out map[string]interface{}) error {
} }
n["interface_addresses"] = straddrs n["interface_addresses"] = straddrs
n["online"] = online
out["net"] = n out["net"] = n
return nil return nil
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论