Skip to content

Commit

Permalink
Merge pull request #2867 from ipfs/feature/api-offline
Browse files Browse the repository at this point in the history
Add way to check if node is online or offline
  • Loading branch information
whyrusleeping committed Jun 19, 2016
2 parents 2a3bba3 + c10ed85 commit a6fb581
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
10 changes: 8 additions & 2 deletions core/commands/sysdiag.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -130,6 +135,7 @@ func netInfo(out map[string]interface{}) error {
}

n["interface_addresses"] = straddrs
n["online"] = online
out["net"] = n
return nil
}
3 changes: 2 additions & 1 deletion test/sharness/t0151-sysdiag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" '
Expand Down

0 comments on commit a6fb581

Please sign in to comment.