提交 a6fb5813 作者: Jeromy Johnson 提交者: GitHub

Merge pull request #2867 from ipfs/feature/api-offline

Add way to check if node is online or offline
......@@ -44,8 +44,13 @@ Prints out information about your computer to aid in easier debugging.
res.SetError(err, cmds.ErrNormal)
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 {
res.SetError(err, cmds.ErrNormal)
return
......@@ -117,7 +122,7 @@ func memInfo(out map[string]interface{}) error {
return nil
}
func netInfo(out map[string]interface{}) error {
func netInfo(online bool, out map[string]interface{}) error {
n := make(map[string]interface{})
addrs, err := manet.InterfaceMultiaddrs()
if err != nil {
......@@ -130,6 +135,7 @@ func netInfo(out map[string]interface{}) error {
}
n["interface_addresses"] = straddrs
n["online"] = online
out["net"] = n
return nil
}
......@@ -17,7 +17,8 @@ test_expect_success "ipfs diag sys succeeds" '
test_expect_success "output contains some expected keys" '
grep "virt" output &&
grep "interface_addresses" output &&
grep "arch" output
grep "arch" output &&
grep "online" output
'
test_expect_success "uname succeeds" '
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论