I do know im leaping in on the deep finish. Nonetheless as a part of a course, I want to finish a pattern VPN app – not Uni or Faculty.
I’ve an open VPN configuration in my viewcontroller which reads the .opvn file, then prompts the TunnelPacket.swift
The app says linked, and the VPN says the right server and so forth. Nonetheless, below deal with it simply says N/A, and after I search public IP it returns my regular IP.
Does anybody have any ideas?
import NetworkExtension
class PacketTunnelProvider: NEPacketTunnelProvider {
override func startTunnel(choices: [String : NSObject]?, completionHandler: @escaping (Error?) -> Void) {
// Initialize and configure your tunnel right here.
// This may embody organising a VPN interface, routing, and so forth.
do {
strive setupVirtualInterface()
completionHandler(nil)
} catch {
completionHandler(error)
}
}
override func stopTunnel(with motive: NEProviderStopReason, completionHandler: @escaping () -> Void) {
// Cleanly cease and tear down the tunnel.
teardownVirtualInterface()
completionHandler()
}
// MARK: - Message Dealing with
override func handleAppMessage(_ messageData: Knowledge, completionHandler: ((Knowledge?) -> Void)?) {
// Deal with incoming messages from the app.
let responseData = processMessageData(messageData)
// Reply again if vital
completionHandler?(responseData)
}
// MARK: - Sleep and Wake Administration
override func sleep(completionHandler: @escaping () -> Void) {
// Put together the tunnel to enter a low-power state.
// Instance: suspendNetworkActivity()
completionHandler()
}
override func wake() {
// Restore the tunnel from the low-power state.
// Instance: resumeNetworkActivity()
}
// MARK: - Helper Strategies
personal func setupVirtualInterface() throws {
// Arrange the digital interface or VPN configuration.
// This may embody defining a brand new community interface, setting IP addresses, and so forth.
// Instance: configureVPNInterface()
}
personal func teardownVirtualInterface() {
// Clear up the digital interface or VPN configuration.
// Instance: releaseResources()
}
personal func processMessageData(_ information: Knowledge) -> Knowledge {
// Course of the message information and return a response.
// That is application-specific.
// Instance: analyzeData(information)
return Knowledge() // Return a response or the identical information
}
personal func suspendNetworkActivity() {
// Droop any ongoing community exercise.
// This may embody pausing information switch, closing connections, and so forth.
}
personal func resumeNetworkActivity() {
// Resume community exercise after waking up.
// Reestablish connections, resume information switch, and so forth.
}
// Extra strategies may be added right here primarily based in your particular necessities.
}
Assist with finalising the connection to retrieve VPN standing with IP deal with.