How can I make some apps not use VPN proxy?

I use NEVPNManager to creat Personal VPN (IKEV2 & IPSec). It works well. But when I use NEProxySettings add white list or proxyAutoConfigurationJavaScript code, it doesn't work. What I want to do is specify that part of the APP doesn't use the VPN proxy, such as, my own App, after connecting to the VPN, network requests can become very slow. Here is my code:

NEVPNProtocolIKEv2 *vpnProtocollIKEv2 = [[NEVPNProtocolIKEv2 alloc] init];
NEProxySettings *proxySettings = [[NEProxySettings alloc] init];
NEProxyServer *httpsServer = [[NEProxyServer alloc] initWithAddress:ip port:port];
proxySettings.HTTPSServer = httpsServer;
NEProxyServer *httpServer = [[NEProxyServer alloc] initWithAddress:ip port:port];
proxySettings.HTTPServer = httpServer;
proxySettings.autoProxyConfigurationEnabled = NO;
proxySettings.excludeSimpleHostnames = YES;
proxySettings.HTTPEnabled = YES;
proxySettings.HTTPSEnabled = YES;
proxySettings.exceptionList = @[@“xxx.xxxx.xxx”]; // domain name
vpnProtocollIKEv2.proxySettings = proxySettings;

There is a question here, is the proxy server necessary, if so, then how to set up the proxy server? I tried to set up a local server with GCDWebServer, but the test found that it didn't work either. In addition, VPN can be started directly in the system Settings, so there is no need to start the APP every time, so the local server seems to be meaningless.

I've also tried adding JS code:

NEProxySettings *set = [[NEProxySettings alloc] init];
set.autoProxyConfigurationEnabled = YES;
//set.proxyAutoConfigurationURL = [NSURL URLWithString:@"https://zxkw.oss-cn-hangzhou.aliyuncs.com/vpn-app/KHTProxyAutoConfiguration.pac"];
set.proxyAutoConfigurationJavaScript = @"function FindProxyForURL(url, host) { return \"DIRECT\";}";

What should I do?

Are you related to zxkw, who seems to be asking the same questions over on this thread.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

A little bit. I just want to know how to control some apps from using VPN proxy when NEVpnManager is used. I don't know if I'm making myself clear. There seems to be no specific plan or method.

I just want to know how to control some apps

You’re using Personal VPN. This uses the Apple VPN transports, like IKEv2. In this configuration they operation in destination IP mode, not source app mode (aka per-app VPN). Trying to emulate per-app VPN with a destination IP transport is not something that DTS supports because:

  • The system wasn’t designed with this in mind.

  • While you might be able to get some things working, our experience is that such solutions are very brittle.

TN3120 Expected use cases for Network Extension packet tunnel providers discusses this in more detail.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Now the question is, I don't know how NEPacketTunnelProvider implements protocol ikev2&ipsec, is there any similar case?

I don't know how NEPacketTunnelProvider implements protocol ikev2 & ipsec

Re-implementing one of the built-in VPN transports is not something I recommend. It would be a lot of work.

is there any similar case?

And it’s likely to have similar restrictions.

Stepping back, what are you trying to achieve here? Let’s ignore APIs for the moment, and focus on user-level behaviour. What behaviour do you want?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thanks! I have found a solution.

How can I make some apps not use VPN proxy?
 
 
Q