Hydra VPN SDK demo for Windows
This repository contains demo application that demonstrates usage of Hydra VPN Windows SDK.
Requirements
This project is based on default Microsoft Visual Studio build process. Hydra VPN Windows SDK requires .Net Framework 4.5. Demo application requires Microsoft Visual Studio 2017. Demo application installs TAP driver and Windows service at startup. If something goes wrong run tap\[32bit|64bit]\install-tap.bat
as Administrator to install TAP driver. Use service\install.bat
and service\uninstall.bat
when you need to manage Windows service manually.
Adding SDK to project
Put the SDK binaries in a suitable place
Reference SDK binaries
Add
Unity
NuGet package reference (Unity at www.nuget.org)Make sure your project is targeting at least .Net Framework 4.5
Now you're all set.
TAP driver installation
To install TAP driver, you need to go to the tap
folder and execute install-tap.bat
from 32bit
folder for Windows x86 or from 64bit
folder for Windows x64 as Administrator.
Windows service installation
To be able to use the hydra service you need to install it into the system once. It could be done by following command:
where serviceName
is the name of your service.
Usage and core interfaces
SDK contains one core interface - IHydraSdk
.
IHydraSdk
To be able to work with hydra sdk, you need to bootstrap hydra by providing valid backend server configuration and hydra configuration. This could be done by using following code snippet (you need to reference Hydra.Sdk.Windows
, Hydra.Sdk.Common
and Hydra.Sdk.Backend
assemblies):
If you need to specify bypass domains or disable automatic reconnection after coming back from sleep mode, set corresponding hydra configuration properties before bootstrapping:
After bootstrapping you can get the backend service instance by simply resolving IHydraSdk
from IoC container:
Login example
Login process requires OAuth Access Token and Authentication Method. This example uses Anonymous and GitHub for demonstration. Do not forget to check whether the request was successful:
After successful login you can execute other methods which requires to be logged in.
Connect example
To be able to successfully connect to the VPN server, you need to execute next three steps:
Bootstrap hydra SDK
Perform login
Call
StartVpn
method
An example of connect implementation:
Disconnect from VPN with:
Change country
Getting available countries list:
GetCountries
response contains list of VpnServerCountry
items. Response must also be checked for OK status. VpnServerCountry
contains information about available Country and Servers, and is used to specify the required country for VPN connection.
Check remaining traffic limit
User can check remaining traffic limit if it is set:
GetRemainingTrafficResponse
contains information about:
Is unlimited - connection to unlimited flag
Traffic start - beginning session time
Traffic limit - limit for traffic usage in bytes
Traffic used - used traffic for subscriber
Traffic remaining - remaining traffic in bytes
OAuth or Anonymous authorization
This example application uses two types of client authorization: with OAuth token and Anonymous.
Usage:
AuthMethod
- one of the valid authentication methods:GitHub, Facebook, Twitter, Firebase, Live, Google - for public authentication servers
OAuth - for custom authentication server
Custom - for custom authentication scheme
Anonymous - for anonymous authentication
DeviceId
- unique device idMachineName
- name of your machineDeviceType
- Desktop or MobileOAuthToken
- valid token from OAuth server ornull
for Anonymous
Log out user with:
Last updated