Pass 1 at adding DNS to controller

This commit is contained in:
Grant Limberg 2020-07-20 14:34:19 -07:00
parent 8eb453e042
commit 387039456d
No known key found for this signature in database
GPG key ID: 2BA62CCABBB4095A
5 changed files with 164 additions and 1 deletions

View file

@ -176,6 +176,15 @@ bool NetworkConfig::toDictionary(Dictionary<ZT_NETWORKCONFIG_DICT_CAPACITY> &d,b
}
}
tmp->clear();
if (dnsCount > 0) {
tmp->append(dnsCount);
DNS::serializeDNS(*tmp, dns, dnsCount);
if (tmp->size()) {
if (!d.add(ZT_NETWORKCONFIG_DICT_KEY_DNS,*tmp)) return false;
}
}
delete tmp;
} catch ( ... ) {
delete tmp;
@ -354,6 +363,13 @@ bool NetworkConfig::fromDictionary(const Dictionary<ZT_NETWORKCONFIG_DICT_CAPACI
unsigned int p = 0;
Capability::deserializeRules(*tmp,p,this->rules,this->ruleCount,ZT_MAX_NETWORK_RULES);
}
if (d.get(ZT_NETWORKCONFIG_DICT_KEY_DNS, *tmp)) {
unsigned int p = 0;
this->dnsCount = tmp->at<unsigned int>(p);
p += sizeof(unsigned int);
DNS::deserializeDNS(*tmp, p, dns, (this->dnsCount <= ZT_MAX_NETWORK_DNS) ? this->dnsCount : ZT_MAX_NETWORK_DNS);
}
}
//printf("~~~\n%s\n~~~\n",d.data());