Skip to main content

Basic SDK Functions

The functions below are essential to start, stop and communicate with the VPN SDK.

User login credentials needed

You must have an active user account in order to create a minimum viable VPN product. Press the 'Add a New User' button at https://app.vpnwholesaler.com/users to create one.

At the bare minimum and considering that you already have login credentials for an active VPN account, you should implement the following functions and commands in order to create a minimum viable VPN product:

  1. Initialize SDK
  2. Set API domain
  3. Login
  4. Set VPN type
  5. Start VPN connection
  6. Stop VPN connection
  7. Finalize SDK

Initialize SDK​

Intializes the SDK with a callback and sets necessary path to OpenVPN binary.

Login required: No

Code: InitOVSCore

Input:

vpnsdk = VPNSDKLib()
vpnsdk.InitOVSCore(self)

Response:

int - returns 0 if SDK was intialized sucessfully and other value in case of failure

Finalize SDK​

Unloads SDK and finalizes all running threads. It is necessary to call this method before exit to avoid leaks.

Login required: No

Code: FinalizeOVSCore()

Input: None

Response: None

Code sample:

FinalizeOVSCore();

Send command​

Asynchronously sends command to SDK. Command result will be returned by calling the callback that was specified on initialization.

All operations in SDK are called asynchronously, and therefore a single callback is used to receive responses from all SDK functions. All responses are encoded as JSON and described in the relevant sections.

Login required: Depending on the command

CmdProc Code: vpnsdk.CmdProc

Input:

{
vpnsdk.CmdProc(CmdProc Code, ["dataObject" : "data"])
}

Response: Generally, responses carry the following JSON structure:

{
"code": integer
"err": integer
"data": { object }
}

Where:

code - the invoked command's notification event. err - error code. data - response based on the notification code.