CustomDNS, UserDNS, MultiHop, VpnProfiles
The VPN SDK provides several powerful features that allow users to customize and optimize their VPN experience. These capabilities include:
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.
VpnProfiles can be received from the GetLocations
response. To apply a VPN Profile:
Call
GetCredentials(GetCredentialsRequest request)
Launch
StartVPN
var sdk = new SDK();
var loginRequest = new LoginRequest
{
Method = AuthenticationMethod.Anonymous.ToString(),
Token = null,
};
var loginResponse = await sdk.LoginAsync(loginRequest).ConfigureAwait(false);
var getLocationsRequest = new GetLocationsRequest
{
AccessToken = loginResponse.AccessToken,
Protocol = Core.Model.Enums.Protocol.HydraTcp,
};
var getLocationsResponse = await sdk.GetLocationsAsync(getLocationsRequest).ConfigureAwait(false);
var selectedLocation = getLocationsResponse.VpnCustomLocations.FirstOrDefault();
var profile = getLocationsResponse.Profiles.FirstOrDefault();
var getCredentialsRequest = new GetCredentialsRequest
{
AccessToken = loginResponse.AccessToken,
VpnNode = selectedLocation,
WithCertificate = true,
Protocol = Core.Model.Enums.Protocol.HydraTcp,
Profile = profile.Name, // Use profile name here
};
var getCredentialsResponse = await sdk.GetCredentialsAsync(getCredentialsRequest).ConfigureAwait(false);
var startVpnRequest = new StartVpnRequest()
{
AccessToken = loginResponse.AccessToken,
Credentials = getCredentialsResponse.Credentials,
EnableKillSwitch = false,
VpnNode = selectedLocation,
};
var startVpnResponse = await sdk.StartVpnAsync(startVpnRequest).ConfigureAwait(false);
CustomDNS
CustomDNS allows setting up custom DNS profiles to direct all DNS requests to the desired server instead of the default ones.
CustomDNS settings can be received from the GetLocations
response. To apply custom DNS:
Call
GetCredentials(GetCredentialsRequest request)
Launch
StartVPN
var sdk = new SDK();
var loginRequest = new LoginRequest
{
Method = AuthenticationMethod.Anonymous.ToString(),
Token = null,
};
var loginResponse = await sdk.LoginAsync(loginRequest).ConfigureAwait(false);
var getLocationsRequest = new GetLocationsRequest
{
AccessToken = loginResponse.AccessToken,
Protocol = Core.Model.Enums.Protocol.HydraTcp,
};
var getLocationsResponse = await sdk.GetLocationsAsync(getLocationsRequest).ConfigureAwait(false);
var selectedLocation = getLocationsResponse.VpnCustomLocations.FirstOrDefault();
var customDnsServer = getLocationsResponse.DnsServers.FirstOrDefault();
var getCredentialsRequest = new GetCredentialsRequest
{
AccessToken = loginResponse.AccessToken,
VpnNode = selectedLocation,
WithCertificate = true,
Protocol = Core.Model.Enums.Protocol.HydraTcp,
CustomDns = customDnsServer, // Use custom DNS server here
};
var getCredentialsResponse = await sdk.GetCredentialsAsync(getCredentialsRequest).ConfigureAwait(false);
var startVpnRequest = new StartVpnRequest()
{
AccessToken = loginResponse.AccessToken,
Credentials = getCredentialsResponse.Credentials,
EnableKillSwitch = false,
VpnNode = selectedLocation,
};
var startVpnResponse = await sdk.StartVpnAsync(startVpnRequest).ConfigureAwait(false);
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:
Call
GetCredentials(GetCredentialsRequest request)
Launch
StartVPN
var userDns = "example";
var sdk = new SDK();
var loginRequest = new LoginRequest
{
Method = AuthenticationMethod.Anonymous.ToString(),
Token = null,
};
var loginResponse = await sdk.LoginAsync(loginRequest).ConfigureAwait(false);
var getLocationsRequest = new GetLocationsRequest
{
AccessToken = loginResponse.AccessToken,
Protocol = Core.Model.Enums.Protocol.HydraTcp,
};
var getLocationsResponse = await sdk.GetLocationsAsync(getLocationsRequest).ConfigureAwait(false);
var selectedLocation = getLocationsResponse.VpnCustomLocations.FirstOrDefault();
var customDnsServer = getLocationsResponse.DnsServers.FirstOrDefault();
var getCredentialsRequest = new GetCredentialsRequest
{
AccessToken = loginResponse.AccessToken,
VpnNode = selectedLocation,
WithCertificate = true,
Protocol = Core.Model.Enums.Protocol.HydraTcp,
UserDns = string.IsNullOrEmpty(userDns) ? customDnsServer.Name : userDns, // Use user DNS server here
};
var getCredentialsResponse = await sdk.GetCredentialsAsync(getCredentialsRequest).ConfigureAwait(false);
var startVpnRequest = new StartVpnRequest()
{
AccessToken = loginResponse.AccessToken,
Credentials = getCredentialsResponse.Credentials,
EnableKillSwitch = false,
VpnNode = selectedLocation,
};
var startVpnResponse = await sdk.StartVpnAsync(startVpnRequest).ConfigureAwait(false);
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 locationUseProxyOptimal
to use the optimal hop location
Example of launching Hydra with Optimal MultiHop location:
var sdk = new SDK();
var loginRequest = new LoginRequest
{
Method = AuthenticationMethod.Anonymous.ToString(),
Token = null,
};
var loginResponse = await sdk.LoginAsync(loginRequest).ConfigureAwait(false);
var getLocationsRequest = new GetLocationsRequest
{
AccessToken = loginResponse.AccessToken,
Protocol = Core.Model.Enums.Protocol.HydraTcp,
};
var getLocationsResponse = await sdk.GetLocationsAsync(getLocationsRequest).ConfigureAwait(false);
var selectedLocation = getLocationsResponse.VpnCustomLocations.FirstOrDefault();
selectedLocation.ProxyOptimal = true;
var getCredentialsRequest = new GetCredentialsRequest
{
AccessToken = loginResponse.AccessToken,
VpnNode = selectedLocation,
WithCertificate = true,
Protocol = Core.Model.Enums.Protocol.HydraTcp,
};
var getCredentialsResponse = await sdk.GetCredentialsAsync(getCredentialsRequest).ConfigureAwait(false);
var startVpnRequest = new StartVpnRequest()
{
AccessToken = loginResponse.AccessToken,
Credentials = getCredentialsResponse.Credentials,
EnableKillSwitch = false,
VpnNode = selectedLocation,
};
var startVpnResponse = await sdk.StartVpnAsync(startVpnRequest).ConfigureAwait(false);
Example of launching Hydra with Custom MultiHop location:
var getLocationsResponse = await sdk.GetLocationsAsync(getLocationsRequest).ConfigureAwait(false);
var selectedLocation = getLocationsResponse.VpnCustomLocations.FirstOrDefault();
selectedLocation.ProxyLocation = getLocationsResponse.VpnCustomLocations
.FirstOrDefault(x => x.Location != selectedLocation.Location).Location;
var getCredentialsRequest = new GetCredentialsRequest
{
AccessToken = loginResponse.AccessToken,
VpnNode = selectedLocation,
WithCertificate = true,
Protocol = Core.Model.Enums.Protocol.HydraTcp,
};
var getCredentialsResponse = await sdk.GetCredentialsAsync(getCredentialsRequest).ConfigureAwait(false);
var startVpnRequest = new StartVpnRequest()
{
AccessToken = loginResponse.AccessToken,
Credentials = getCredentialsResponse.Credentials,
EnableKillSwitch = false,
VpnNode = selectedLocation,
};
var startVpnResponse = await sdk.StartVpnAsync(startVpnRequest).ConfigureAwait(false);
Last updated
Was this helpful?