在越狱的iOS环境(11.3.1)中运行此代码时,不会存储新的DNS值:
SCDynamicStoreRef store = SCDynamicStoreCreate(kCFAllocatorDefault, CFSTR("init_by_defaults_systemconfiguration"), NULL, NULL);
CFStringRef key = CFSTR("State:/Network/Global/DNS");
CFDictionaryRef dnsDict = (CFDictionaryRef)SCDynamicStoreCopyValue(store, key);
//Create new values
CFMutableDictionaryRef newdnsDict = CFDictionaryCreateMutableCopy(NULL,0,dnsDict);
CFMutableArrayRef newdnsServerAddresses = CFArrayCreateMutable(NULL,0,NULL);
CFArrayAppendValue(newdnsServerAddresses, CFSTR("8.8.8.8"));
CFArrayAppendValue(newdnsServerAddresses, CFSTR("8.8.4.4"));
CFDictionarySetValue(newdnsDict, CFSTR("ServerAddresses"), newdnsServerAddresses);
SCDynamicStoreSetValue(store, key, newdnsDict);
//Clean up
CFRelease(store);
CFRelease(key);
CFRelease(dnsDict);
CFRelease(newdnsServerAddresses);
CFRelease(newdnsDict);
我知道自运行以来就没有存储该值
scutil --dns
我看不到新的DNS值。