CustomDNS, UserDNS, MultiHop, VpnProfiles

Use GetLocations for MultiHop, custom DNS and VPN profiles functionalities instead of GetNodes

The VPN SDK provides several powerful features that allow users to customize and optimize their VPN experience. These capabilities include:

Feature
Description

VpnProfiles

Create separate VPN profiles for various purposes (e.g., work, streaming, general browsing), allowing quick switching between appropriate servers without manual reconfiguration.

CustomDNS

Set up custom DNS profiles to direct all DNS requests to the desired server instead of the default ones.

UserDNS

Enables setting up user-defined DNS servers for handling DNS requests.

MultiHop

Routes the VPN connection through an intermediate server before reaching the main VPN server for enhanced privacy and security.

VpnProfiles

VpnProfiles allow creating separate profiles for various purposes (e.g. work, streaming, general browsing), enabling quick switching between appropriate servers without manual reconfiguration each time.

Can be received from GetLocations response.

VpnProfiles can be received from the GetLocations response. To apply a VPN Profile:

  1. Call GetCredentials(GetCredentialsRequest request)

  2. Launch StartVPN

var getLocations = await GetLocations(Protocol.Hydra, "carrier");
var profile = getLocations.Profiles.FirstOrDefault();
var getCredentialsRequest = new GetCredentialsRequest
{
    AppVersion = appVersion,
    Protocol = protocol,
    Profile = profile.,
    VpnNode = vpnNode,
    WithCertificate = withCertificate,
    DeviceId = DEVICEID,
};

var getCredentialsResponse = await GetCredentials(getCredentialsRequest);      

var startVpnRequest = new StartVpnRequest
{
    Credentials = getCredentialsResponse.Credentials,
    DeviceId = DEVICEID,
    EnableKillSwitch = false,
    EnableTunnelLogging = false,
    VpnNode = getNodesResponse.VpnCountries.FirstOrDefault(),
};

var startVpnResponse = sdk.StartVpn(startVpnRequest);

CustomDNS

CustomDNS allows setting up custom DNS profiles to direct all DNS requests to the desired server instead of the default ones.

Can be received from GetLocations response.

CustomDNS settings can be received from the GetLocations response. To apply custom DNS:

  1. Call GetCredentials(GetCredentialsRequest request)

  2. Launch StartVPN

var getLocations = await GetLocations(Protocol.Hydra, "carrier");
var customDnsServer = getLocations.DnsServers.FirstOrDefault();
var getCredentialsRequest = new GetCredentialsRequest
{
    AppVersion = appVersion,
    Protocol = protocol,
    CustomDns = customDnsServer,
    VpnNode = vpnNode,
    WithCertificate = withCertificate,
    DeviceId = DEVICEID, 
};

var response = await GetCredentials(getCredentialsRequest);         

var startVpnRequest = new StartVpnRequest
{
    Credentials = getCredentialsResponse.Credentials,
    DeviceId = DEVICEID,
    EnableKillSwitch = false,
    EnableTunnelLogging = false,
    VpnNode = getNodesResponse.VpnCountries.FirstOrDefault(),
};

var startVpnResponse = sdk.StartVpn(startVpnRequest);

UserDNS

UserDNS allows setting up user-defined DNS servers to direct all DNS requests to the desired server instead of the default ones.

To apply UserDNS:

  1. Call GetCredentials(GetCredentialsRequest request)

  2. Launch StartVPN

var getLocations = await GetLocations(Protocol.Hydra, "carrier");
var customDnsServer = getLocations.DnsServers.FirstOrDefault();
var request = new GetCredentialsRequest()
{
    AppVersion = appVersion,
    Protocol = protocol,
    UserDns = customDnsServer,
    VpnNode = vpnNode,
    WithCertificate = withCertificate,
    DeviceId = DEVICEID,
};

var response = await GetCredentials(request);         

var startVpnRequest = new StartVpnRequest
{
    Credentials = getCredentialsResponse.Credentials,
    DeviceId = DEVICEID,
    EnableKillSwitch = false,
    EnableTunnelLogging = false,
    VpnNode = getNodesResponse.VpnCountries.FirstOrDefault(),
};

var startVpnResponse = sdk.StartVpn(startVpnRequest);

MultiHop

MultiHop routes the VPN connection through an intermediate server before reaching the main VPN server for enhanced privacy and security.

Settuped hop location can be used with the ProxyLocation property to specify some location or UseProxyOptimal to use the optimal hop location.

The hop location can be specified using:

  • ProxyLocation property to specify a location

  • UseProxyOptimal to use the optimal hop location

Example of launching Hydra with Optimal MultiHop location:

var getLocations= sdk.GetLocations(Protocol.Hydra, "carrier");

var node = getLocations.VpnCustomLocations.FirstOrDefault();
node.ProxyOptimal = true;

var getCredentialsRequest = new GetCredentialsRequest
{
    VpnNode = node,
    WithCertificate = true,
    Protocol = protocol,
    AppVersion = AppVersion,
    DeviceId = DEVICEID,
};

var credentialsResponse = await GetCredentials(request);         

var startVpnRequest = new StartVpnRequest
    {
        Credentials = credentialsResponse.Credentials,
        DeviceId = DEVICEID,
        EnableKillSwitch = false,
        EnableTunnelLogging = false,
        VpnNode = getLocations.VpnCountries.FirstOrDefault(),
    };    
var startVpnResponse = sdk.StartVpn(startVpnRequest);  

Example of launching Hydra with Custom MultiHop location:

var getLocations = sdk.GetLocations(Protocol.Hydra, "carrier");

var node = getLocations.VpnCustomLocations.FirstOrDefault();
node.ProxyLocation = getLocations.VpnCustomLocations
            .FirstOrDefault(x => x.Location != node.Location).Location;

var getCredentialsRequest = new GetCredentialsRequest
{
    VpnNode = node,
    WithCertificate = true,
    Protocol = protocol,
    AppVersion = AppVersion,
    DeviceId = DEVICEID,
};

var credentialsResponse= await GetCredentials(getCredentialsRequest);         

var startVpnRequest = new StartVpnRequest
{
    Credentials = credentialsResponse.Credentials,
    DeviceId = DEVICEID,
    EnableKillSwitch = false,
    EnableTunnelLogging = false,
    VpnNode = getLocations.VpnCountries.FirstOrDefault(),
};

var startVpnResponse = sdk.StartVpn(startVpnRequest);

Last updated