Obtaining the IP address of Mac OS X Proxy

I am trying to programmatically get the IP address or proxy server URLs installed on the system.
I found code that might work in the previous question here , but it is in Objective-C and what I'm trying to use is simple C.

I tried to translate this obj-c code to C, but did not succeed.

Does anyone know how to get a system proxy in C?

thanks

+6
source share
1 answer

This is a C translation that answers :

CFDictionaryRef proxies = SCDynamicStoreCopyProxies(NULL); if (proxies) { CFStringRef pacURL = (CFStringRef)CFDictionaryGetValue(proxies, kSCPropNetProxiesProxyAutoConfigURLString); if (pacURL) { char url[257] = {}; CFStringGetCString(pacURL, url, sizeof url, kCFStringEncodingASCII); // do something with url } CFRelease(proxies); } 

It must be associated with two structures: SystemConfiguration and CoreFoundation.

Please note that this code gets the URL to automatically configure the proxy server ( kSCPropNetProxiesProxyAutoConfigURLString ), if any. There are several other possible proxies. HTTP proxy or HTTPS proxy. For a list of all possible proxy servers, see SCSchemaDefinitions Link .

+4
source

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


All Articles