So i'm trying to get the proxy info on an iOS device. The OS handily provides use with a function CFNetworkCopySystemProxySettings() to get a dictionary of the settings. When the host and port are provided I have no issue, I can access them in the dictionary with the kCFNetworkProxiesHTTPProxy, and kCFNetworkProxiesHTTPPort keys respectively. However, sometimes these are not provided and instead a URL is provided for the kCFNetworkProxiesProxyAutoConfigURLString key. Now this is where I'm getting the problem...
So I pull the file, which contains a javascript function as expected:
function FindProxyForURL(url,host)
{
if (isInNet(host, "10.xxx.xxx.xxx", "255.255.224.0"))
{
return "DIRECT";
}
if (isInNet(host, "10.xxx.xxx.xxx", "255.255.224.0"))
{
return "DIRECT";
}
return "PROXY host:port";
}
which all looks good to me..?
Then, I try to call the function and get the return value, this is where it all goes wrong :( Here's my most recent attempt:
NSString *jsFunction = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; // jsFunction is the javascript function above
JSContext *context= [[JSContext alloc] init];
[context evaluateScript:jsFunction];
JSValue *function = context[@"FindProxyForURL"];
JSValue *jsResult = [function callWithArguments:@[[JSValue valueWithObject:[NSString stringWithCppString:host] inContext:context], [JSValue valueWithObject:[NSString stringWithCppString:host] inContext:context]]];
NSString *result = [jsResult toString];
And result always comes back as undefined!!
I have tried a few test functions in place of the PAC that just increment numbers and they work as expected, the issue seems to begin when I introduce a call to isInNet. Has anyone had a similar issue? Is isInNet not supported in iOS? Am I doing something obviously wrong?
Thanks for any help you can offer!