Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion osdep/MacDNSHelper.mm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "MacDNSHelper.hpp"

#include <stdio.h>
#include <sys/utsname.h>

#include <SystemConfiguration/SystemConfiguration.h>

Expand All @@ -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<InetAddress> &servers)
{
SCDynamicStoreRef ds = SCDynamicStoreCreate(NULL, CFSTR("zerotier"), NULL, NULL);
Expand Down Expand Up @@ -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);
Expand Down