fix memory init issue

and another place where dns data needs to be copied
This commit is contained in:
Grant Limberg 2020-07-31 11:42:03 -07:00
parent 6b197e067a
commit d098a99d09
No known key found for this signature in database
GPG key ID: 2BA62CCABBB4095A
9 changed files with 47 additions and 4 deletions

View file

@ -501,6 +501,7 @@ public:
settings.allowManaged = true;
settings.allowGlobal = false;
settings.allowDefault = false;
memset(&config, 0, sizeof(ZT_VirtualNetworkConfig));
}
std::shared_ptr<EthernetTap> tap;
@ -831,7 +832,7 @@ public:
Mutex::Lock _l(_nets_m);
for(std::map<uint64_t,NetworkState>::iterator n(_nets.begin());n!=_nets.end();++n) {
if (n->second.tap)
syncManagedStuff(n->second,false,true);
syncManagedStuff(n->second,false,true,false);
}
}
}
@ -1117,7 +1118,7 @@ public:
}
if (n->second.tap)
syncManagedStuff(n->second,true,true);
syncManagedStuff(n->second,true,true,true);
return true;
}
@ -1864,7 +1865,7 @@ public:
}
// Apply or update managed IPs for a configured network (be sure n.tap exists)
void syncManagedStuff(NetworkState &n,bool syncIps,bool syncRoutes)
void syncManagedStuff(NetworkState &n,bool syncIps,bool syncRoutes, bool syncDns)
{
char ipbuf[64];
@ -1984,6 +1985,26 @@ public:
#endif
}
}
if (syncDns) {
char buf[128];
if (n.config.dnsCount > ZT_MAX_NETWORK_DNS) {
fprintf(stderr, "ERROR: %d records > max %d. Skipping DNS\n", n.config.dnsCount, ZT_MAX_NETWORK_DNS);
return;
}
fprintf(stderr, "Syncing %d DNS configurations\n", n.config.dnsCount);
for (int i = 0; i < n.config.dnsCount; ++i) {
if (strlen(n.config.dns[i].domain) != 0) {
fprintf(stderr, "Syncing DNS for domain: %s\n", n.config.dns[i].domain);
for (int j = 0; j < ZT_MAX_DNS_SERVERS; ++j) {
InetAddress a(n.config.dns[i].server_addr[j]);
if (a.isV4() || a.isV6()) {
fprintf(stderr, "\t Server %d: %s\n", j+1, a.toIpString(buf));
}
}
}
}
}
}
// =========================================================================
@ -2333,7 +2354,7 @@ public:
Sleep(10);
}
#endif
syncManagedStuff(n,true,true);
syncManagedStuff(n,true,true,true);
n.tap->setMtu(nwc->mtu);
} else {
_nets.erase(nwid);