VPN
The KapeVPN module provides everything needed for VPN connectivity: server discovery, VPN profile
management, tunnel lifecycle, and connection status. It supports both WireGuard, Lightway and OpenVPN protocols.
Guides
- Connecting — connection modes, status, errors
- VPN Protocol — selecting WireGuard, Lightway or OpenVPN, and the network transport (TCP/UDP)
- Server Locations — fetching and filtering locations
- Dedicated IP — listing Anonymous and Simple Dedicated IPs, and reserving a Simple one
- OpenVPN Endpoint Configuration — the full OpenVPN payload and its credentials, without the tunnel dependencies
- Network Extension — Packet Tunnel Provider setup
- Network Protection — kill switch, split tunneling, on-demand rules, custom DNS
- HTTPS Proxy — routing Lightway TCP through a client-supplied HTTPS proxy
- Connection Analytics —
VpnConnectionAnalyticsreliability events - IPv6 Leak Prevention — how IPv6 is blackholed across all protocols
- Licensed VPN features — which features your SDK license gates, and what happens without them
Complete Example
import KapeAuth
import KapeCore
import KapeVPN
// Initialize
let settings = try KapeSDKSettings()
let handle = try KapeSdkHandle(settings: settings)
// Authenticate
let auth = KapeAuthClient(handle: handle)
try await auth.login(presenting: viewController)
// Activate subscription
try handle.activateSubscription(for: .custom(values: ["xv.vpn"]))
// Fetch locations
let locations = KapeLocationService(handle: handle)
try await locations.fetchLocations()
// Connect — auto picks the highest-rated smart location
let vpn = KapeVPNManager(handle: handle)
try await vpn.installProfile()
try await vpn.connect(mode: .auto)
// Or connect to a specific server
// try await vpn.connect(mode: .manual(locationId: locations.allLocations.first!.id))
// Observe
vpn.$connectionStatus.sink { print($0) }
// Later: disconnect
await vpn.disconnect()
// Signing out: tear the tunnel and its configuration down, then log out
await vpn.signOut()
try await auth.logout()