Hello, my goal is that when a request comes in with a specified ip using vpn, it sents to a localhost 8080 web server I created using gcdwebserver so I created NEPacketTunnelProvider and set some proxy server by using NEPacketTunnelProvider. However, when I configure it as below, and connect to the ip in the browser, it shows web server result I want but I can't access the other site like apple.com.
let settings: NEPacketTunnelNetworkSettings = NEPacketTunnelNetworkSettings(tunnelRemoteAddress: "77.77.77.77")
settings.dnsSettings = NEDNSSettings(servers: ["8.8.8.8", "8.8.4.4"])
let proxySettings: NEProxySettings = NEProxySettings()
proxySettings.httpServer = NEProxyServer(
address: proxyHost,
port: proxyPort
)
proxySettings.httpsServer = NEProxyServer(
address: proxyHost,
port: proxyPort
)
proxySettings.autoProxyConfigurationEnabled = false
proxySettings.httpEnabled = true
proxySettings.httpsEnabled = true
proxySettings.excludeSimpleHostnames = true
settings.proxySettings = proxySettings
let ipv4Settings: NEIPv4Settings = NEIPv4Settings(
addresses: [settings.tunnelRemoteAddress],
subnetMasks: ["255.255.255.255"]
)
ipv4Settings.includedRoutes = [NEIPv4Route.default()]
settings.ipv4Settings = ipv4Settings
So, I set includeRoutes to only allow specified ip (77.77.77.77) as below, and the internet works fine, but access to the the ip is failed. It shows "connection failed" in the browser. Am I trying something wrong?
ipv4Settings.includedRoutes = [
NEIPv4Route(destinationAddress: "77.77.77.77", subnetMask: "255.255.255.255")
]