问题
Considering my application has the user ID and Password for the admin user currently logged in, is it possible to retrieve the configuration values from the OSX Network settings? Particularly interested in the "Advanced/Proxies" tab content.
回答1:
Did it with the settings API. Here's an example to fetch the PAC URL string from the 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;
回答2:
Look at the scutil
command. In particular, scutil --proxy
will show the proxies
来源:https://stackoverflow.com/questions/4327582/programmatically-retrieve-osx-network-proxies-configuration-values