SDK Unified VPN SDK for Windows Features Hydra Protocol 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:
Create separate VPN profiles for various purposes (e.g., work, streaming, general browsing), allowing quick switching between appropriate servers without manual reconfiguration.
Set up custom DNS profiles to direct all DNS requests to the desired server instead of the default ones.
Enables setting up user-defined DNS servers for handling DNS requests.
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)
Copy 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
{
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()
{
Credentials = getCredentialsResponse.Credentials,
AccessToken = loginResponse.AccessToken,
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)
Copy 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
{
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()
{
Credentials = getCredentialsResponse.Credentials,
AccessToken = loginResponse.AccessToken,
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)
Copy 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
{
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()
{
Credentials = getCredentialsResponse.Credentials,
AccessToken = loginResponse.AccessToken,
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 location
UseProxyOptimal
to use the optimal hop location
Example of launching Hydra with Optimal MultiHop location:
Copy 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
{
VpnNode = selectedLocation,
WithCertificate = true,
Protocol = Core.Model.Enums.Protocol.HydraTcp,
};
var getCredentialsResponse = await sdk.GetCredentialsAsync(getCredentialsRequest).ConfigureAwait(false);
var startVpnRequest = new StartVpnRequest()
{
Credentials = getCredentialsResponse.Credentials,
AccessToken = loginResponse.AccessToken,
EnableKillSwitch = false,
VpnNode = selectedLocation,
};
var startVpnResponse = await sdk.StartVpnAsync(startVpnRequest).ConfigureAwait(false);
Example of launching Hydra with Custom MultiHop location:
Copy 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
{
VpnNode = selectedLocation,
WithCertificate = true,
Protocol = Core.Model.Enums.Protocol.HydraTcp,
};
var getCredentialsResponse = await sdk.GetCredentialsAsync(getCredentialsRequest).ConfigureAwait(false);
var startVpnRequest = new StartVpnRequest()
{
Credentials = getCredentialsResponse.Credentials,
AccessToken = loginResponse.AccessToken,
EnableKillSwitch = false,
VpnNode = selectedLocation,
};
var startVpnResponse = await sdk.StartVpnAsync(startVpnRequest).ConfigureAwait(false);