Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put tags and capabilities in network json #2139

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions include/ZeroTierOne.h
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,14 @@ typedef struct
* sso provider
**/
char ssoProvider[64];

uint32_t tags[ZT_MAX_NETWORK_TAGS][2];
unsigned int tagsCount;

uint32_t capabilities[ZT_MAX_NETWORK_CAPABILITIES];
unsigned int capabilitiesCount;


} ZT_VirtualNetworkConfig;

/**
Expand Down
19 changes: 19 additions & 0 deletions node/Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1492,6 +1492,25 @@ void Network::_externalConfig(ZT_VirtualNetworkConfig *ec) const
ec->portError = _portError;
ec->netconfRevision = (_config) ? (unsigned long)_config.revision : 0;

for (unsigned int i = 0; i<ZT_MAX_NETWORK_TAGS; i++) {
if (_config.tags[i].id()) {
ec->tags[i][0] = _config.tags[i].id();
ec->tags[i][1] = _config.tags[i].value();
} else {
ec->tagsCount = i;
break;
}
}

for (unsigned int i = 0; i<ZT_MAX_NETWORK_CAPABILITIES; i++) {
if (_config.capabilities[i].id()) {
ec->capabilities[i] = _config.capabilities[i].id();
} else {
ec->capabilitiesCount = i;
break;
}
}

ec->assignedAddressCount = 0;
for(unsigned int i=0;i<ZT_MAX_ZT_ASSIGNED_ADDRESSES;++i) {
if (i < _config.staticIpCount) {
Expand Down
23 changes: 23 additions & 0 deletions service/OneService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,29 @@ static void _networkToJson(nlohmann::json &nj,NetworkState &ns)
nj["allowDefault"] = localSettings.allowDefault;
nj["allowDNS"] = localSettings.allowDNS;

nlohmann::json tags = nlohmann::json::array();
for(unsigned int i=0;i<ns.config().tagsCount;++i) {
if (ns.config().tags[i]) {
nlohmann::json tag = nlohmann::json::array();
tag = ns.config().tags[i];
tags[i] = tag;
} else {
break;
}
}
nj["tags"] = tags;

nlohmann::json caps = nlohmann::json::array();
for(unsigned int i=0;i<ns.config().capabilitiesCount;++i) {
if (ns.config().capabilities[i]) {
caps[i] = ns.config().capabilities[i];
} else {
break;
}
}
nj["capabilities"] = caps;


nlohmann::json aa = nlohmann::json::array();
for(unsigned int i=0;i<ns.config().assignedAddressCount;++i) {
aa.push_back(reinterpret_cast<const InetAddress *>(&(ns.config().assignedAddresses[i]))->toString(tmp));
Expand Down
Loading