Skip to main content

VPN Status

The commands below are useful once VPN connection has been successfully established.

Get VPN Status​

Requests current VPN connection status.

Login required: Yes

CmdProc Code: OVS_CMD_GET_STATUS

Command number: 5

Input: Not required

Response: OVS_NOTIFY_GET_STATUS

OVS_NOTIFY_GET_STATUS Successful response
OVS_ERR_OK

{
"VPN_Status": 1
}

VPN_Status will contain one of the following values:

  1. VPN_NOTIFY_CONNECTING
  2. VPN_NOTIFY_CONNECTED
  3. VPN_NOTIFY_DISCONNECTED
  4. VPN_NOTIFY_CONN_FAILED
  5. VPN_NOTIFY_ABNORMALLY_DISCONNECTED
  6. VPN_NOTIFY_AUTH
  7. VPN_NOTIFY_ASSIGNIP
  8. VPN_NOTIFY_GETCONFIG

Code sample:

VPNSDK.CommandNotifyCB callback = new VPNSDK.CommandNotifyCB() {
@Override
public void onNotify(int notification, int error, Object data) {
if (error == VPNSDK.OVS_ERROR_CODES.OVS_ERR_OK) {
int state = (Integer)((Map)data).get("VPN_Status");
switch (state) {
case VPNSDK.VPN_NOTIFY_STATUS.VPN_NOTIFY_DISCONNECTED:
case VPNSDK.VPN_NOTIFY_STATUS.VPN_NOTIFY_ABNORMALLY_DISCONNECTED:
case VPNSDK.VPN_NOTIFY_STATUS.VPN_NOTIFY_CONN_FAILED: {
// Do something when VPN was disconnected
break;
}
case VPNSDK.VPN_NOTIFY_STATUS.VPN_NOTIFY_ASSIGNIP:
case VPNSDK.VPN_NOTIFY_STATUS.VPN_NOTIFY_GETCONFIG:
case VPNSDK.VPN_NOTIFY_STATUS.VPN_NOTIFY_AUTH:
case VPNSDK.VPN_NOTIFY_STATUS.VPN_NOTIFY_CONNECTING: {
// Do something when VPN was started to connect
break;
}
case VPNSDK.VPN_NOTIFY_STATUS.VPN_NOTIFY_CONNECTED: {
// Do something when VPN was connected
break;
}
}
} else {
// Process error
}
}
};
VPNSDK.CmdProc(VPNSDK.OVS_CMD_CODES.OVS_CMD_GET_STATUS, callback);

Get Active VPN Profile​

Returns the active VPN connection parameters - server, protocol and port.

Login required: Yes

CmdProc Code: OVS_CMD_GET_CURRENT_PROFILE

Command number: 17

Input: Not required

Response: OVS_NOTIFY_GET_CURRENT_PROFILE

OVS_NOTIFY_GET_CURRENT_PROFILE Successful response
OVS_ERR_OK

data will return

{
"server_ip": "104.192.3.90",
"protocol": "tcp",
"server_port": 1194
}

Code sample:

VPNSDK.CommandNotifyCB callback = new VPNSDK.CommandNotifyCB() {
@Override
public void onNotify(int notification, int error, Object data) {
if (error == VPNSDK.OVS_ERROR_CODES.OVS_ERR_OK) {
// Do something when command is successful
} else {
// Process error
}
}
};
VPNSDK.CmdProc(VPNSDK.OVS_CMD_CODES.OVS_CMD_GET_CURRENT_PROFILE, callback);

Enable IO Counter​

Enables of disables IO counter.

Login required: Yes

CmdProc Code: OVS_CMD_SET_IOCOUNT

Command number: 15

Input:

{
"status": true|false
}

Status indicates whether IO counter should be enabled or not.

Response: OVS_NOTIFY_SET_IOCOUNT

OVS_NOTIFY_SET_IOCOUNT Successful response
OVS_NOTIFY_SET_IOCOUNT
data is null

While IO counter is enabled then SDK keeps issuing the OVS_NOTIFY_VPN_IOCOUNT notification

Data field of OVS_NOTIFY_VPN_IOCOUNT will have the following structure:

{
"data_in": 0,
"speed_in": 0,
"data_out": 0,
"speed_out": 0
}

Where:

  • data_in - Downloaded data amount
  • speed_in - Current download speed
  • data_out - Uploaded data amount
  • speed_out - Current upload speed

Code sample:

VPNSDK.CommandNotifyCB callback = new VPNSDK.CommandNotifyCB() {
@Override
public void onNotify(int notification, int error, Object data) {
if (error == VPNSDK.OVS_ERROR_CODES.OVS_ERR_OK) {
// Do something when command is successful
} else {
// Process error
}
}
};
VPNSDK.CmdProc(VPNSDK.OVS_CMD_CODES.OVS_CMD_SET_IOCOUNT, callback, true);