diff --git a/osdep/MacDNSHelper.mm b/osdep/MacDNSHelper.mm index 973e51c45..cd8913636 100644 --- a/osdep/MacDNSHelper.mm +++ b/osdep/MacDNSHelper.mm @@ -9,6 +9,7 @@ #include "MacDNSHelper.hpp" #include +#include #include @@ -19,6 +20,15 @@ static void printKeys (const void* key, const void* value, void* context) { CFShow(value); } +static int darwin_version_major () { + int version_major = -1; + struct utsname system_info; + if (uname(&system_info) == 0) { + sscanf(system_info.release, "%d", &version_major); + } + return version_major; +} + void MacDNSHelper::setDNS(uint64_t nwid, const char *domain, const std::vector &servers) { SCDynamicStoreRef ds = SCDynamicStoreCreate(NULL, CFSTR("zerotier"), NULL, NULL); @@ -164,8 +174,10 @@ static void printKeys (const void* key, const void* value, void* context) { values[3] = cfrouter; + // skip setting Router to avoid breaking the routing table on MacOS Tahoe and later + static int size = darwin_version_major() < 25 ? SIZE : SIZE - 1; CFDictionaryRef dict = CFDictionaryCreate(NULL, - (const void**)keys, (const void**)values, SIZE, &kCFCopyStringDictionaryKeyCallBacks, + (const void**)keys, (const void**)values, size, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); // CFDictionaryApplyFunction(dict, printKeys, NULL);