我的应用程序IPv4
使用NEPacketTunnelProvider
. 隧道系统运行良好,但在 IPv6 中无法运行。
我正在尝试使我的VPN
应用程序适应ipv6
环境,但我不知道如何开始,请告诉我该怎么做。
这是我的代码:
let newSettings = NEPacketTunnelNetworkSettings(tunnelRemoteAddress: "127.0.0.1")
let ip = "32.432.53.1"
let subnet = "10.3.21.1"
newSettings.ipv4Settings = NEIPv4Settings(addresses: [ip], subnetMasks: [subnet])
newSettings.mtu = 1432
newSettings.ipv4Settings?.includedRoutes = [NEIPv4Route.default()]
newSettings.ipv6Settings?.includedRoutes = [NEIPv6Route.default()]
newSettings.dnsSettings = NEDNSSettings(servers: ["8.8.8.8"])
let endPoint = NWHostEndpoint(hostname: "12.432.55.22", port: 9090)
var session = self.createUDPSession(to: endPoint, from: nil)
self.session?.writeDatagram(newData, completionHandler: { (error) in
})
self.session?.setReadHandler({ (newPackets: [Data]?, error: Error?) -> Void in
}, maxDatagrams: NSIntegerMax)