Skip to main content

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​

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()