Add external listening addr/port pairs to status output (ticket #1555)

This commit is contained in:
Joseph Henry 2022-02-07 10:08:02 -08:00
parent 4190318c85
commit 926b2e168e
No known key found for this signature in database
GPG Key ID: C45B33FF5EBC9344

View File

@ -1504,25 +1504,19 @@ public:
res["config"] = _localConfig; res["config"] = _localConfig;
} }
json &settings = res["config"]["settings"]; json &settings = res["config"]["settings"];
settings["primaryPort"] = OSUtils::jsonInt(settings["primaryPort"],(uint64_t)_primaryPort) & 0xffff;
settings["allowTcpFallbackRelay"] = OSUtils::jsonBool(settings["allowTcpFallbackRelay"],_allowTcpFallbackRelay); settings["allowTcpFallbackRelay"] = OSUtils::jsonBool(settings["allowTcpFallbackRelay"],_allowTcpFallbackRelay);
/* settings["primaryPort"] = OSUtils::jsonInt(settings["primaryPort"],(uint64_t)_primaryPort) & 0xffff;
if (_node->bondController()->inUse()) { settings["secondaryPort"] = OSUtils::jsonInt(settings["secondaryPort"],(uint64_t)_secondaryPort) & 0xffff;
json &multipathConfig = res["bonds"]; settings["tertiaryPort"] = OSUtils::jsonInt(settings["tertiaryPort"],(uint64_t)_tertiaryPort) & 0xffff;
ZT_PeerList *pl = _node->peers(); // Enumerate all external listening address/port pairs
char peerAddrStr[256]; std::vector<InetAddress> boundAddrs(_binder.allBoundLocalInterfaceAddresses());
if (pl) { auto boundAddrArray = json::array();
for(unsigned long i=0;i<pl->peerCount;++i) { for (int i = 0; i < boundAddrs.size(); i++) {
if (pl->peers[i].isBonded) { char ipBuf[64] = { 0 };
nlohmann::json pj; boundAddrs[i].toString(ipBuf);
_bondToJson(pj,&(pl->peers[i])); boundAddrArray.push_back(ipBuf);
OSUtils::ztsnprintf(peerAddrStr,sizeof(peerAddrStr),"%.10llx",pl->peers[i].address);
multipathConfig[peerAddrStr] = (pj);
} }
} settings["listeningOn"] = boundAddrArray;
}
}
*/
#ifdef ZT_USE_MINIUPNPC #ifdef ZT_USE_MINIUPNPC
settings["portMappingEnabled"] = OSUtils::jsonBool(settings["portMappingEnabled"],true); settings["portMappingEnabled"] = OSUtils::jsonBool(settings["portMappingEnabled"],true);