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.

PropertyDescription

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.

There are two options for retrieving the list of servers.

The user must be entitled in order to use the method listServers(cachePolicy:). This method updates an internal cache which is required in order for a connection to complete, so there may be efficiency gains to using this method once the user has been confirmed to be entitled.

Note that it is not mandatory for clients to call this method explicitly, however it will be called internally upon connection, if its internal cache has not already been populated.

Unentitled users must use the paginated method

  listServers(
      countriesFilter: [],
      limit:,
      nextToken:,
      cachePolicy:)

to retrieve a list of servers, which can be filtered by an array of ISO3166 Alpha-2 two letter country codes. The limit and nextToken parameters are used to paginate through a potentially large list. This method uses an independent cache.

Each method will either return a list of valid servers to connect to, or an empty list if none are available. In the event of an error, a SudoVPNError will be thrown.

An example for unentitled users is:

var allServers: [SudoVPNServer] = []
do {
    var serverResult = 
        try await vpnClient.listServers(
            countriesFilter: ["AU"], 
            limit: 2000, 
            nextToken: nil)
    allServers.append(contentsOf: serverResult.items)
    // If you wish to handle all retrievals in a single task context
    while serverResult.nextToken != nil {
      serverResult = 
          try await vpnClient.listServers(
              countriesFilter:["AU"],
              limit: 2000,
              nextToken: serverResult.nextToken)
} catch {
    // Handle errors
}

And for entitled users:

var allServers: [SudoVPNServer] = []
do {
    allServers = 
        try await vpnClient.listServers(cachePolicy: .remoteOnly)
} catch {
    // Handle errors
}

Last updated