Skip to content

AVVPNService simplifies setup of the VPN (IPSec or IKEv2)

License

Notifications You must be signed in to change notification settings

AcceleratorYY/AVVPNService

 
 

Repository files navigation

AVVPNService

Version License Platform

Requirements

  • iOS 9.3+
  • Swift 5

Installation

CocoaPods

To integrate AVVPNService into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'AVVPNService'

Swift Package Manager

Swift Package Manager is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.

Xcode 11+ is required to build AVVPNService using Swift Package Manager.

To integrate AVVPNService into your Xcode project using Swift Package Manager, add it to the dependencies value of your Package.swift:

dependencies: [
    .package(url: "https://github.com/AndreVasilev/AVVPNService.git", .upToNextMajor(from: "0.1.4"))
]

Manually

If you prefer not to use either of the aforementioned dependency managers, you can integrate AVVPNService into your project manually.

Just add files from Sources/AVVPNService directory to your project.

Usage

Select Signing & Capabilities pane of the project editor -> Add Personal VPN capability

import AVVPNService

// Initialize Credentials
let credentials = Credentials.IPSec(server: "", username: "", password: "", shared: "")
// or
let credentials = Credentials.IKEv2(server: "", username: "", password: "", remoteId: "", localId: "")

// Connect
AVVPNService.shared.connect(credentialas) { error in
// Handle error
}

//Disconnect
AVVPNService.shared.disconnect()

You can also observe NEVPNStatus

import AVVPNService
import NetworkExtension

// Set delegate
AVVPNService.shared.delegate = self

// and conform to AVVPNServiceDelegate
func vpnService(_ service: AVVPNService, didChange status: NEVPNStatus)

Or subscribe NEVPNStatusDidChange notification

import AVVPNService
import NetworkExtension

NotificationCenter.default.addObserver(self, selector: #selector(didChangeStatus(_:)), name: NSNotification.Name.NEVPNStatusDidChange, object: nil)

@objc func didChangeStatus(_ notification: Notification) {
    if let connection = notification.object as? NEVPNConnection {
        print(connection.statu)
    }
}

Author

Andrey Vasilev ([email protected])

Credits

Create a key chain for Apple's VPN, Moataz Elmasry

License

AVVPNService is available under the MIT license. See the LICENSE file for more info.

About

AVVPNService simplifies setup of the VPN (IPSec or IKEv2)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 94.3%
  • Ruby 5.7%