mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 20:43:44 +02:00
Merge pull request #1388 from emundo/fix/1387-dns-issue
Fix macOS DNS issue
This commit is contained in:
commit
5fb814a04f
1 changed files with 20 additions and 11 deletions
|
@ -39,8 +39,14 @@ void MacDNSHelper::setDNS(uint64_t nwid, const char *domain, const std::vector<I
|
||||||
sprintf(buf, "State:/Network/Service/%.16llx/DNS", nwid);
|
sprintf(buf, "State:/Network/Service/%.16llx/DNS", nwid);
|
||||||
CFStringRef key = CFStringCreateWithCString(NULL, buf, kCFStringEncodingUTF8);
|
CFStringRef key = CFStringCreateWithCString(NULL, buf, kCFStringEncodingUTF8);
|
||||||
CFArrayRef list = SCDynamicStoreCopyKeyList(ds, key);
|
CFArrayRef list = SCDynamicStoreCopyKeyList(ds, key);
|
||||||
|
|
||||||
CFIndex i = 0, j = CFArrayGetCount(list);
|
CFIndex i = 0, j = CFArrayGetCount(list);
|
||||||
|
bool dnsServersChanged = true;
|
||||||
|
CFPropertyListRef oldDNSServers = NULL;
|
||||||
|
if (j > 0) {
|
||||||
|
oldDNSServers = SCDynamicStoreCopyValue(ds, (CFStringRef)CFArrayGetValueAtIndex(list, i));
|
||||||
|
dnsServersChanged = !CFEqual(oldDNSServers,dict);
|
||||||
|
}
|
||||||
|
if (dnsServersChanged) {
|
||||||
bool ret = TRUE;
|
bool ret = TRUE;
|
||||||
if (j <= 0) {
|
if (j <= 0) {
|
||||||
ret &= SCDynamicStoreAddValue(ds, key, dict);
|
ret &= SCDynamicStoreAddValue(ds, key, dict);
|
||||||
|
@ -50,7 +56,10 @@ void MacDNSHelper::setDNS(uint64_t nwid, const char *domain, const std::vector<I
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
fprintf(stderr, "Error writing DNS configuration\n");
|
fprintf(stderr, "Error writing DNS configuration\n");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (oldDNSServers != NULL) {
|
||||||
|
CFRelease(oldDNSServers);
|
||||||
|
}
|
||||||
CFRelease(list);
|
CFRelease(list);
|
||||||
CFRelease(key);
|
CFRelease(key);
|
||||||
CFRelease(dict);
|
CFRelease(dict);
|
||||||
|
|
Loading…
Add table
Reference in a new issue