Post not yet marked as solved
Post marked as unsolved with 8 replies, 562 views
I am trying to set up an HTTP proxy that can be used system-wide from an app.
After some research, it looks like the CoreFoundation library's CFNetworkExecuteProxyAutoConfigurationScript() function can be used to configure the proxy.
(1) Is it possible to set the HTTP proxy available system-wide with CFNetworkExecuteProxyAutoConfigurationScript()?
(2) I tried the following source code but "EXC_BAD_ACCESS" occurs and the callback block is not called. Do you know what is the problem?
(void)startNextRequest
{
Request *request = _requests.firstObject;
if (request == nil) {
return;
}
CFStreamClientContext context;
memset(&context, 0, sizeof(CFStreamClientContext));
context.info = (__bridge void * _Null_unspecified)(self);
CFRunLoopSourceRef rls =
CFNetworkExecuteProxyAutoConfigurationScript(
(__bridge CFStringRef _Nonnull)(_script),
(__bridge CFURLRef _Nonnull)(request.targetURL),
(__bridge void *)^(PACResolver *client, CFArrayRef proxies, CFErrorRef error) {
[client resolveDidFinishWithProxies:proxies error:error];
},
&context);
assert(_runLoopSource == nil);
_runLoopSource = rls;
CFRunLoopAddSource(CFRunLoopGetCurrent(), rls, kCFRunLoopDefaultMode); }
Environment:
Xcode 13.1
iPad 8th gen.
iOS 14.0.1