diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2014-02-14 16:23:03 -0800 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2014-02-14 16:23:03 -0800 |
| commit | 4ec7cd2760ae8e4b6502aad3400f1c4827a2cfbc (patch) | |
| tree | aa0505581f1cdb17cac12d62cfbc1679de5ec26e /node/NodeConfig.cpp | |
| parent | b0277ab904f0a5b6227ea234665e633171aa3962 (diff) | |
| download | infinitytier-4ec7cd2760ae8e4b6502aad3400f1c4827a2cfbc.tar.gz infinitytier-4ec7cd2760ae8e4b6502aad3400f1c4827a2cfbc.zip | |
Fix for GitHub issue #38: compute whether we are ONLINE a little differently
Diffstat (limited to 'node/NodeConfig.cpp')
| -rw-r--r-- | node/NodeConfig.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/node/NodeConfig.cpp b/node/NodeConfig.cpp index 88776a1b..6093d6ad 100644 --- a/node/NodeConfig.cpp +++ b/node/NodeConfig.cpp @@ -195,15 +195,20 @@ std::vector<std::string> NodeConfig::execute(const char *command) _P("200 help terminate [<reason>]"); _P("200 help updatecheck"); } else if (cmd[0] == "info") { + // We are online if at least one supernode has spoken to us since the last time our + // network environment changed and also less than ZT_PEER_LINK_ACTIVITY_TIMEOUT ago. bool isOnline = false; uint64_t now = Utils::now(); + uint64_t since = _r->timeOfLastNetworkEnvironmentChange; std::vector< SharedPtr<Peer> > snp(_r->topology->supernodePeers()); for(std::vector< SharedPtr<Peer> >::const_iterator sn(snp.begin());sn!=snp.end();++sn) { - if ((*sn)->hasActiveDirectPath(now)) { + uint64_t lastRec = (*sn)->lastDirectReceive(); + if ((lastRec)&&(lastRec > since)&&((now - lastRec) < ZT_PEER_LINK_ACTIVITY_TIMEOUT)) { isOnline = true; break; } } + _P("200 info %s %s %s",_r->identity.address().toString().c_str(),(isOnline ? "ONLINE" : "OFFLINE"),Node::versionString()); } else if (cmd[0] == "listpeers") { _P("200 listpeers <ztaddr> <ipv4> <ipv6> <latency> <version>"); |
