Programmatically Retrieve OSX Network/Proxies configuration values

╄→гoц情女王★ 提交于 2020-01-01 14:07:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!