Skip to main content

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:

PropertyTypeDescription
IdstringLocation ID (pass to KapeConnectionMode.Manual)
NamestringHuman-readable name (e.g. "Frankfurt")
CountrystringCountry display name; empty until the daemon has loaded region metadata
CountryCodestringISO 3166-1 alpha-2 country code, e.g. "US"
PingMsint?Round-trip time in milliseconds; null if not yet measured
OfflineboolTrue 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.