VPN
KapeVpnManager provides everything needed for VPN connectivity: connection
lifecycle, protocol selection, and kill switch and split tunnel configuration.
KapeLocationService provides the server list. The daemon executes; the
library observes and controls.
Guides
- Connecting — connect, disconnect, status, errors
- VPN Protocol — selecting Lightway, OpenVPN, or WireGuard
- Server Locations — the pushed server list
- Network Protection — kill switch modes
- Split Tunnel — per-app and per-subnet routing
Complete Example
using Kape.Core;
using Kape.Vpn;
await using var handle = await KapeSdkHandle.CreateAsync();
var vpn = new KapeVpnManager(handle);
vpn.ConnectionStatusChanged += status => Console.WriteLine($"VPN: {status}");
vpn.ConnectionError += error => Console.WriteLine($"Error: {error}");
// Pick the first online location
var locations = new KapeLocationService(handle);
var location = (await locations.FetchLocationsAsync()).First(l => !l.Offline);
await vpn.SetSelectedProtocolAsync(KapeVpnProtocol.Lightway, KapeVpnTransport.Udp);
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
await vpn.ConnectAsync(location, cts.Token);
Console.WriteLine($"Connected via {vpn.ConnectedProtocol}, IP {vpn.ExternalVpnIp}");
// Later: disconnect
await vpn.DisconnectAsync();