99#include " MacDNSHelper.hpp"
1010
1111#include < stdio.h>
12+ #include < sys/utsname.h>
1213
1314#include < SystemConfiguration/SystemConfiguration.h>
1415
@@ -19,6 +20,15 @@ static void printKeys (const void* key, const void* value, void* context) {
1920 CFShow (value);
2021}
2122
23+ static int darwin_version_major () {
24+ int version_major = -1 ;
25+ struct utsname system_info;
26+ if (uname (&system_info) == 0 ) {
27+ sscanf (system_info.release , " %d" , &version_major);
28+ }
29+ return version_major;
30+ }
31+
2232void MacDNSHelper::setDNS (uint64_t nwid, const char *domain, const std::vector<InetAddress> &servers)
2333{
2434 SCDynamicStoreRef ds = SCDynamicStoreCreate (NULL , CFSTR (" zerotier" ), NULL , NULL );
@@ -164,8 +174,10 @@ static void printKeys (const void* key, const void* value, void* context) {
164174 values[3 ] = cfrouter;
165175
166176
177+ // skip setting Router to avoid breaking the routing table on MacOS Tahoe and later
178+ static int size = darwin_version_major () < 25 ? SIZE : SIZE - 1 ;
167179 CFDictionaryRef dict = CFDictionaryCreate (NULL ,
168- (const void **)keys, (const void **)values, SIZE , &kCFCopyStringDictionaryKeyCallBacks ,
180+ (const void **)keys, (const void **)values, size , &kCFCopyStringDictionaryKeyCallBacks ,
169181 &kCFTypeDictionaryValueCallBacks );
170182
171183 // CFDictionaryApplyFunction(dict, printKeys, NULL);
0 commit comments