Commit a6fb5813 authored by Jeromy Johnson's avatar Jeromy Johnson Committed by GitHub

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

Add way to check if node is online or offline
parents 2a3bba3a c10ed855
......@@ -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 is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment