/VPNManager

Cocoa Framework for VPN Connection Wrapper

Primary LanguageSwiftMIT LicenseMIT

BetterVPNManager cocoapodsCarthage compatible Swift 5.0

How to get started

CocoaPods

platform :ios, '11.0'

# You need to set target when you use CocoaPods 1.0.0 or later.
target 'SampleTarget' do
  use_frameworks!
  pod 'BetterVPNManager'
end

Methods

//Import Framework
import BetterVPNManager

//Create your VPN Manager variable
let vpn = VPNManager.shared
vpn.delegate = self 

//Create your VPN Account and configurations
let vpnAccount = VPNAccount(type: VPNProtocolType.IKEv2, title: "TITLE SEEN IN SETTINGS", server: "IP HERE", account: "bd2147240ab2471d", groupName: "Group Name Of Your VPN", remoteId: "Remote IP Address(Same most of the time)", alwaysOn: true)

//Set your account password and secret
vpnAccount.passwordRef = "YourVPNPassword".data(using: .utf8)
//If you are using IPSec you can use this in order to set secret
vpnAccount.secretRef = "YourVPNSecret".data(using: .utf8)
//Note : If you want to secure you secrets and passwords for your VPN you can use some Keychain wrapper 

//Save and connect your 
vpn.saveAndConnect(account : vpnAccount)

//Only Save account then connect
vpn.save(account : vpnAccount)
vpn.connect()

//Disconnect
vpn.disconnect()

//Remove saved Account
vpn.removeProfile()

//Config On Demand (Connect only on request is made)
vpn.configOnDemand()

Delegate Methods

VPNManagerDelegate Methods:

public func VpnManagerConnectionFailed(error : VPNCollectionErrorType , localizedDescription : String)

This called when connection failed with error type and description

public func VpnManagerConnected()

This method called when connection established successfully

public func VpnManagerDisconnected()

This method called when disconnect action made successfully

public func VpnManagerProfileSaved()

This method called when you save your VPN account

public func VpnManagerProfileDeleted()

This method called when you delete your VPN account

Requirements

  • Swift 5
  • iOS 11.0 or above.

License

MIT