Search…
Manage Servers
Provides your users with the ability to list servers used to establish a connection.
The VPN SDK provides a set of APIs to allow your users to manage the servers they choose to use to establish a VPN connection.
The SudoVPNServer object contains information about the server.
Property
Description
country
The ISO 3166-1 Alpha-2 code of the country location.
region
The region within the server country location (e.g. Florida).
coordinates
Longitude and latitude coordinates of the server location.
load
Server utilization which ranges from 0-100. 0 is low, whereas 100 is high.
ipAddress
IP Address of the server.

Retrieving Servers

In order to establish a connection using the VPN SDK, a server is required. A list of available servers can be retrieved using the list servers API.
iOS
Android
Servers are retrieved by using the method listServers(completion:). The method will either return a list of valid servers to connect to, or an empty list if none are available.
An example implementation is:
1
vpnClient.listServers { result in
2
switch result {
3
case let .failure(cause):
4
/// Handle/notify user of error
5
case let .success(servers):
6
/// `servers` is the retrieved array of `SudoVPNServer` objects,
7
/// or empty array if no objects are available.
8
}
Copied!
A call to the listServers method provides a list of servers that can be used to establish a connection. An example implementation of retrieving the available servers is:
1
launch {
2
try {
3
val servers = withContext(Dispatchers.IO) {
4
vpnClient.listServers()
5
}
6
// If no exception is thrown then the list of [servers] is returned.
7
} catch (e: SudoVPNException) {
8
// Handle/notify user of exception
9
}
10
}
Copied!
The call to listServers will return the list of available servers. If an exception occurs, the e.localizedMessage can be presented to the user to notify them as to what caused the exception.
Last modified 7mo ago
Copy link