mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-19 04:57:53 +00:00
GitHub issue #111
This commit is contained in:
parent
d8d4aace42
commit
52314dcdf6
@ -138,7 +138,7 @@ void NodeControlService::_doCommand(IpcConnection *ipcc,const char *commandLine)
|
||||
if (cmd[0] == "info") {
|
||||
ipcc->printf("200 info %.10llx %s %s"ZT_EOL_S,_node->address(),(_node->online() ? "ONLINE" : "OFFLINE"),Node::versionString());
|
||||
} else if (cmd[0] == "listpeers") {
|
||||
ipcc->printf("200 listpeers <ztaddr> <paths> <latency> <version>"ZT_EOL_S);
|
||||
ipcc->printf("200 listpeers <ztaddr> <paths> <latency> <version> <role>"ZT_EOL_S);
|
||||
ZT1_Node_PeerList *pl = _node->listPeers();
|
||||
if (pl) {
|
||||
for(unsigned int i=0;i<pl->numPeers;++i) {
|
||||
@ -175,7 +175,17 @@ void NodeControlService::_doCommand(IpcConnection *ipcc,const char *commandLine)
|
||||
(pl->peers[i].paths[j].fixed ? "fixed" : (pl->peers[i].paths[j].active ? "active" : "inactive")));
|
||||
}
|
||||
}
|
||||
ipcc->printf(" %u %s"ZT_EOL_S,pl->peers[i].latency,(pl->peers[i].remoteVersion[0]) ? pl->peers[i].remoteVersion : "-");
|
||||
const char *rolestr;
|
||||
switch(pl->peers[i].role) {
|
||||
case ZT1_Node_Peer_SUPERNODE: rolestr = "SUPERNODE"; break;
|
||||
case ZT1_Node_Peer_HUB: rolestr = "HUB"; break;
|
||||
case ZT1_Node_Peer_NODE: rolestr = "NODE"; break;
|
||||
default: rolestr = "?"; break;
|
||||
}
|
||||
ipcc->printf(" %u %s %s"ZT_EOL_S,
|
||||
pl->peers[i].latency,
|
||||
((pl->peers[i].remoteVersion[0]) ? pl->peers[i].remoteVersion : "-"),
|
||||
rolestr);
|
||||
}
|
||||
_node->freeQueryResult(pl);
|
||||
}
|
||||
|
@ -203,6 +203,15 @@ struct ZT1_Node_Peer
|
||||
*/
|
||||
unsigned int latency;
|
||||
|
||||
/**
|
||||
* What trust hierarchy role does this device have?
|
||||
*/
|
||||
enum {
|
||||
ZT1_Node_Peer_SUPERNODE = 0, // planetary supernode
|
||||
ZT1_Node_Peer_HUB = 1, // locally federated hub (coming soon)
|
||||
ZT1_Node_Peer_NODE = 2 // ordinary node
|
||||
} role;
|
||||
|
||||
/**
|
||||
* Array of network paths to peer
|
||||
*/
|
||||
|
@ -847,6 +847,7 @@ ZT1_Node_PeerList *Node::listPeers()
|
||||
p->first->address().toString(prec->address,sizeof(prec->address));
|
||||
prec->rawAddress = p->first->address().toInt();
|
||||
prec->latency = p->first->latency();
|
||||
prec->role = RR->topology->isSupernode(p->first->address()) ? ZT1_Node_Peer_SUPERNODE : ZT1_Node_Peer_NODE;
|
||||
|
||||
prec->paths = (ZT1_Node_PhysicalPath *)buf;
|
||||
buf += sizeof(ZT1_Node_PhysicalPath) * p->second.size();
|
||||
|
Loading…
Reference in New Issue
Block a user