Server Locations
Fetching Locations
The daemon loads the server list itself and keeps it fresh; there is nothing to
refresh from the application. FetchLocationsAsync returns the list, waiting
for the daemon to load it when it is still empty right after start-up:
using Kape.Vpn;
var locations = new KapeLocationService(handle);
var all = await locations.FetchLocationsAsync();
Afterwards the current list is always available as AllLocations, and
LocationsChanged fires whenever the daemon updates it:
locations.AllLocations // IReadOnlyList<KapeServerLocation>
locations.LocationsChanged += all =>
{
foreach (var location in all.Where(l => !l.Offline))
Console.WriteLine($"{location.Country} / {location.Name} {location.PingMs} ms [{location.Id}]");
};
Group by Country or CountryCode for a per-country list:
foreach (var country in all.GroupBy(l => l.CountryCode))
Console.WriteLine($"{country.Key}: {country.Count()} locations");
Data Model
Each KapeServerLocation provides:
| Property | Type | Description |
|---|---|---|
Id | string | Location ID (pass to KapeConnectionMode.Manual) |
Name | string | Human-readable name (e.g. "Frankfurt") |
Country | string | Country display name; empty until the daemon has loaded region metadata |
CountryCode | string | ISO 3166-1 alpha-2 country code, e.g. "US" |
PingMs | int? | Round-trip time in milliseconds; null if not yet measured |
Offline | bool | True while the location is temporarily out of service |
Connecting to a Location
Pass the location to KapeVpnManager — there is no separate select call:
await vpn.ConnectAsync(location);
See Connecting.