Virtual Locations
Implementing Virtual Locations
When implementing virtual locations in your VPN service, you have two primary options for specifying the hop location: optimal location and custom location.
Optimal Location
The optimal location feature allows the VPN SDK to automatically select the best intermediate server for your connection. This is ideal when you want to prioritize performance and let the system handle the routing decisions.
To use the optimal location in your code, you can utilize the VirtualLocation.optimal()
method. Here's an example of how to start a VPN connection with the optimal location:
if you use location: nil
, it's equivalent to location: VirtualLocation.optimal()
. In both cases, the SDK will automatically select an appropriate proxy server.
Custom Location
For users who require more control over their connection routing, the custom location option allows you to specify a particular intermediate server location.
Here's an example of finding a VPN connection with a custom location:
In this example, the intermediate hop is a server in San Jose, United States.
For more information, refer to struct VirtualLocation.
Last updated