Programmatically retrieve OSX Network / Proxies configuration values

Given that my application has a user ID and password for the user who is currently logged in, is it possible to get the configuration values ​​from the OSX Network settings? Particularly interested in the contents of the Advanced / Proxy tab.

+3
source share
2 answers

Did it using the settings API. Here's an example of getting a PAC URL string from OSX network settings.

static char url[257] = {0}; NSDictionary * proxies = (NSDictionary *)SCDynamicStoreCopyProxies(NULL); NSString * pacURL = [proxies objectForKey:(NSString *)kSCPropNetProxiesProxyAutoConfigURLString]; if (NULL != pacURL) { strncpy((char*) (&(url)[0]), [pacURL cStringUsingEncoding:NSASCIIStringEncoding], sizeof(url)); } return url; 
+5
source

Look at the scutil command. In particular, scutil --proxy will show proxies

+3
source

Source: https://habr.com/ru/post/889486/


All Articles