diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-08-06 11:50:56 -0400 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-08-06 11:50:56 -0400 |
commit | 5f8a3f4a7f2eaae3e3091bc4e0dc8977ec597744 (patch) | |
tree | f5e4b0eb370537c8a075249fb6d3940a895faaf8 | |
parent | 499ac2699f5e93e691792790121ed1b4d35da210 (diff) | |
download | infinitytier-5f8a3f4a7f2eaae3e3091bc4e0dc8977ec597744.tar.gz infinitytier-5f8a3f4a7f2eaae3e3091bc4e0dc8977ec597744.zip |
More detail and output improvements to command bus "listpeers," and a little cleanup.
-rw-r--r-- | node/NodeConfig.cpp | 18 | ||||
-rw-r--r-- | node/Peer.hpp | 13 |
2 files changed, 24 insertions, 7 deletions
diff --git a/node/NodeConfig.cpp b/node/NodeConfig.cpp index e87c7ec0..440511e5 100644 --- a/node/NodeConfig.cpp +++ b/node/NodeConfig.cpp @@ -123,11 +123,12 @@ public: { InetAddress v4(p->ipv4ActivePath(_now)); InetAddress v6(p->ipv6ActivePath(_now)); - _P("200 listpeers %s %s %s %d", + _P("200 listpeers %s %s %s %u %s", p->address().toString().c_str(), - ((v4) ? v4.toString().c_str() : "(none)"), - ((v6) ? v6.toString().c_str() : "(none)"), - (((v4)||(v6)) ? (int)p->latency() : -1)); + ((v4) ? v4.toString().c_str() : "-"), + ((v6) ? v6.toString().c_str() : "-"), + (((v4)||(v6)) ? p->latency() : 0), + p->remoteVersion().c_str()); } private: @@ -149,13 +150,14 @@ std::vector<std::string> NodeConfig::execute(const char *command) _P("200 help help"); _P("200 help listpeers"); _P("200 help listnetworks"); - _P("200 help join <network ID> [<network invitation code>]"); + _P("200 help join <network ID>"); _P("200 help leave <network ID>"); } else if (cmd[0] == "listpeers") { + _P("200 listpeers <ztaddr> <ipv4> <ipv6> <latency> <version>"); _r->topology->eachPeer(_DumpPeerStatistics(r)); } else if (cmd[0] == "listnetworks") { Mutex::Lock _l(_networks_m); - _P("200 listnetworks <nwid> <type> <dev> <ips>"); + _P("200 listnetworks <nwid> <status> <type> <dev> <ips>"); for(std::map< uint64_t,SharedPtr<Network> >::const_iterator nw(_networks.begin());nw!=_networks.end();++nw) { std::string tmp; std::set<InetAddress> ips(nw->second->tap().ips()); @@ -164,7 +166,9 @@ std::vector<std::string> NodeConfig::execute(const char *command) tmp.push_back(','); tmp.append(i->toString()); } - _P("200 listnetworks %.16llx %s %s %s", + // TODO: display network status, such as "permission denied to closed + // network" or "waiting". + _P("200 listnetworks %.16llx OK %s %s %s", (unsigned long long)nw->first, (nw->second->isOpen() ? "public" : "private"), nw->second->tap().deviceName().c_str(), diff --git a/node/Peer.hpp b/node/Peer.hpp index 4cc5e0f3..339b9e1a 100644 --- a/node/Peer.hpp +++ b/node/Peer.hpp @@ -348,6 +348,19 @@ public: } /** + * @return Remote version in string form or '?' if unknown + */ + inline std::string remoteVersion() const + { + if ((_vMajor)||(_vMinor)||(_vRevision)) { + char tmp[32]; + sprintf(tmp,"%u.%u.%u",_vMajor,_vMinor,_vRevision); + return std::string(tmp); + } + return std::string("?"); + } + + /** * Get and reset dirty flag * * @return Previous value of dirty flag before reset |