Multihop

Multihop routing is a VPN configuration where the connection is routed through an intermediate server before reaching the main VPN server.

Multihop routing is only available for the Hydra protocol.

Implementing Multihop

To enable multihop routing, you need to pass an additional location to the withLocation method of the SessionConfig.Builder class. Both the main location and the proxy location can be fetched using the Backend API.

Here's an example of how to create a SessionConfig with multihop routing:

SessionConfig sessionConfig = new SessionConfig.Builder()
    .withLocation("US", "YOUR_ACTUAL_PROXY_LOCATION")
    .build();

In this example, "US" is the main location, and "YOUR_ACTUAL_PROXY_LOCATION" is the proxy location.

Fetching Available Virtual Locations

To fetch the available locations for multihop routing, you can use the locations method of the Backend class, specifying the ConnectionType.HYDRA_TCP parameter.

Here's an example of how to fetch the available locations:

UnifiedSdk sdk = UnifiedSdk.getInstance();
sdk.getBackend().locations(ConnectionType.HYDRA_TCP, new Callback<AvailableLocations>() {
   @Override
   public void success(@NonNull AvailableLocations availableLocations) {
        // Handle the available locations
   }
   @Override
   public void failure(@NonNull VpnException e) {
        // Handle any errors
   }
});

Optimal Proxy

To automatically select the optimal proxy location based on network conditions and server load, you can pass an empty string ("") as the proxy parameter in the withLocation method. Passing null as the proxy parameter means that no proxy location is used.

SessionConfig sessionConfig = new SessionConfig.Builder()
    .withLocation("US", "")  // Use optimal proxy
    .build();

Last updated