Komodia's Redirector API Guide

From Komodia
Jump to: navigation, search

This page covers Komodia's Redirector API, this page should be read only after you worked with the Redirector and know how to control it, you can learn more on how to control the Redirector here Komodia's Redirector installation guide.

This page also covers the samples that are provided with the Redirector.

Contents

When to use

The API is used to control all the aspects of the Komodia's Redirector which you are currently doing using the PCController.exe

When deploying the SDK you can :

  1. Use the API (which is detailed below) or
  2. In case your settings are constant, you can set it up once and distribute the INI file with the settings when you install your product (more on the INI files and locations: Komodia's Redirector installation guide#Settings_load_sequence).

Samples

You can download the samples for: C++, VB6, VB.net,C# from Redirector API samples

Important these samples are for the trial version, if you are an existing client you should download the samples from the link provided for you by Komodia after the purchase.

VB6

You will find the VB6 project inside the directory VB6, it's the console we give away with the trials to control the Redirector, it can be quite complex so we recommend to read how the API work or view the VB.Net sample which is more specific.

VB.Net

You will find the VB.Net sample inside the directory C#, this is a small sample that just connects to the Redirector and set the DLL framework. This sample is only a base, you can use the C# code to extend it.

Redirector

This is the main Redirector control sample, inside there are number of methods to control the Redirector:

  • Clear - Clears the redirector data.
  • Load - Loads the data from file.
  • Save - Saves the data to a file.
  • Add ports - Adds ports to the interception list, this can also be used to add applications or IPs, just change the line:
tbl = dc.GetTable(PCProxyLib._Tables.dtPort)

To:

tbl = dc.GetTable(PCProxyLib._Tables.dtApplications)
  • Set proxy - Sets a proxy to redirect intercepted traffic to.
  • Clear proxy - Clear the proxy settings.
  • Save custom data - Shows the user how to save custom data to the Redirector data storage.
  • GetCustomData (Internal function) - Shows how to retrieve the custom data.
  • Connect SSH - Shows how to open a SSH channel (Komodia's Redirector SSH component is an optional component which is needed to be requested during the trial)
  • Kill SSH - Closes the SSH channel.
  • Set DLL - Shows how to set a custom DLL.

Watchdog

This is the sample to control the Komodia's Watchdog (This is an optional module)

Traffic handling samples

This samples shows how to use the Komodia's Redirector COM framework guide.

C#

You will find the VB.Net sample inside the directory C#, this is a small sample that just connects to the Redirector and set the DLL framework. This sample is only a base, you can use the VB.Net code to extend it.

Redirector

This is the main Redirector control sample, inside there are number of methods to control the Redirector:

  • Clear - Clears the redirector data.
  • Load - Loads the data from file.
  • Save - Saves the data to a file.
  • Add ports - Adds ports to the interception list, this can also be used to add applications or IPs, just change the line:
tbl = dc.GetTable(PCProxyLib._Tables.dtPort)

To:

tbl = dc.GetTable(PCProxyLib._Tables.dtApplications)
  • Set proxy - Sets a proxy to redirect intercepted traffic to.
  • Clear proxy - Clear the proxy settings.
  • Save custom data - Shows the user how to save custom data to the Redirector data storage.
  • GetCustomData (Internal function) - Shows how to retrieve the custom data.
  • Connect SSH - Shows how to open a SSH channel (Komodia's Redirector SSH component is an optional component which is needed to be requested during the trial)
  • Kill SSH - Closes the SSH channel.
  • Set DLL - Shows how to set a custom DLL.

Watchdog

This is the sample to control the Komodia's Watchdog (This is an optional module)

Traffic handling samples

This samples shows how to use the Komodia's Redirector COM framework guide.

C++

The C++ sample contains two folders: one for direct usage of the code (you embedd the class) and one to use via a DLL.

CRedirectorControl class

This is the main class used to control the Redirector with direct and DLL method, this is the header:

class CRedirectorControl  
{
public:
	//Set a flag
	static std::wstring SetFlag(const std::wstring& rFlagName,
				    const std::wstring& rParameter);

	//Get the flag
	static std::wstring GetFlag(const std::wstring& rFlagName,
				    std::wstring& rParameter);

	//Set the redirector status
	static std::wstring SetRedirectorEnabled(bool bEnabled);

	//Is the redirector enabled
	static std::wstring IsRedirectorEnabled(bool& rEnabled);

	//Clear the proxy
	static std::wstring ClearProxyInformation();

	//Get the proxy from the redirector
	static std::wstring GetProxyInformation(std::string& rIP,
						unsigned short& rPort,
						std::string& rUsername,
						std::string& rPassword,
						_RD_ProxyType& rType);

	//Set the proxy for the redirector
	static std::wstring SetProxyInformation(const std::string& rIP,
						unsigned short usPort,
						const std::string& rUsername,
						const std::string& rPassword,
						_RD_ProxyType aType);

	//Delete an item
	static std::wstring DeleteItem(_RD_ItemType aItem,
				       const std::wstring& rItem);

	//Get an item
	static std::wstring GetItems(_RD_ItemType aItem);

	//Add an item
	static std::wstring AddItem(_RD_ItemType aItem,
				    const std::wstring& rItem);

	//Do a clear/load/save
	static std::wstring TakeAction(_RD_ActionType aType);

	//Ctor and Dtor
	CRedirectorControl();
	virtual ~CRedirectorControl();
};

The return value of each function is string which denotes if the operation was successful or not:

Success - The string will be empty.

Error - The string will contain the error.

SetFlag

This method sets a flag:

rFlagName - Flag name (flag list will be later in this page)

rParameter - Value to Set.

GetFlag

This method gets the value of a flag:

rFlagName - Flag name.

rParameter - Will contain the value of the flag, if the flag doesn't exists this parameter will remain empty.

SetRedirectorEnabled

This method enable or disable the redirector: (to learn more about disable/enable goto: Komodia's Redirector installation guide#Enable.2Fdisable.

bEnabled - True for enable, False for disable.

IsRedirectorEnabled

This method queries the state of the Redirector:

rEnabled - Will contain the value denoting if the Redirector is enabled or disabled.

Proxy control

You can learn more about proxies here: Komodia's Redirector installation guide#Proxy_control.

Proxy type is chosen with this enum:

typedef enum _RD_ProxyType
{
	ptHTTP,
	ptHTTPConnect,
	ptHTTPConnectSSL,
	ptHTTPHybrid,
	ptHTTPHybridSSL,
	ptSocks4,
	ptSocks5,
	ptNone
} RD_ProxyType;
ClearProxyInformation

This method will clear proxy information.

GetProxyInformation

This method will retreive the current proxy settings:

rIP - Will contain the IP of the proxy.

rPort - Will contain the port of the proxy.

rUsername - Will contain the username of the proxy.

rPassword- Will contain the password of the proxy.

rType- Will contain the type of the proxy.

SetProxyInformation

This method will set the proxy settings:

rIP - IP of the proxy.

rPort - Port of the proxy.

rUsername - Username of the proxy.

rPassword- Password of the proxy.

rType- Type of the proxy.

Items

Item control are used to add, get and remove Applications, ports and IPs. The type is controlled via this enum:

typedef enum _RD_ItemType
{
    itApplication,
    itApplicationInv,
    itPort,
    itPortInv,
    itIP,
    itIPInv,
    itHardExclude = 9,
    itHardInclude,
    itApplicationUDP,
    itPortUDP,
    itIPUDP,
    itApplicationInvUDP,
    itPortInvUDP,
    itIPInvUDP,
    itApplicationTCPI,
    itPortTCPI,
    itIPTCPI,
    itApplicationInvTCPI,
    itPortInvTCPI,
    itIPInvTCPI
} RD_ItemType;
  • The members with the "Inv" at the end denote the list to never intercept (right pane in the PCController when trying to set the interception rules: Komodia's Redirector installation guide#Rules_type.
  • Members that end with UDP are for the UDP interception module.
  • Members that end with TCPI are for the incoming TCP interception module.

All the methods are case insensitive.

DeleteItem

This method deletes an item from the list:

aItem - Item type.

rItem - Item to delete.

AddItem

This method adds an item to the list:

aItem - Item type.

rItem - Item to delete.

GetItems

This method will get all the items inside one of the lists, the data will be delimited by a comma (,):

aItem - Item type.

Return value - The delimited string.

TakeAction

This method clears, saves and loads data according to this enum:

typedef enum _RD_ActionType
{
	atSave,
	atLoad,
	atClear
} RD_ActionType;

aType - Action type.

Direct

The direct samples is using the class directly to control the Redirector, please note that you must initialize COM in the thread that you are using to control the Redirector.

API

This sample shows how to set an application to intercept, save and clear the data.

Header and cookies

This sample shows how to set the headers filtering mechanism and regex cookie processing.

Proxy

This samples shows how to set a proxy.

Traffic handling samples

This samples shows how to use the Komodia's Redirector COM framework guide.

Ad inject with HTTP Parser

This sample shows how to inject an item into a HTML page using the HTTP Parser.

Ad inject with ad injector

This sample shows how to inject an item into a HTML page using the HTTP Parser and ad injector, it will be a little bit faster and a little bit more complex.

Ad injection (using service instead of console)

Service that does ad injection (based on the Ad inject with ad injector sample).

Compiling
  • The main project is InjectorServiceExe
  • The define INJECTION_STRING under KomodiaInject.h sets the data to inject.
  • The define INJECTION_DOMAIN under KomodiaInject.h sets the domain to inject to.
  • The optional define INJECTION_FILE under KomodiaInject.h sets the file name to be read, the file will be loaded from the path of the service, and each line will contain a domain.
Installing

From UAC enabled command prompt (on Windows Vista and above) run:

InjectorServiceExe install auto
sc start InjectorService

It will be running after a reboot since it's installed as automatic start.

Uninstalling

From UAC enabled command prompt (on Windows Vista and above) run:

sc stop InjectorService
InjectorServiceExe uninstall

DLL

The DLL control is good if you plan to use it from a non C++ language, but does supports DLLs (such as Delphi, although it's possible to use COM directly from Delphi)

RedirectorControlDLL

Is the project to compile the DLL.

TestControlDLL

Is the sample of how to interface with the DLL.

LSP Installer DLL Control

This sample is given only after purchase of the SDK and it contains code to install/uninstall the LSP and service. It also shows to get list of all installed LSPs.

Starting and shutting down the service

Service start

When starting the service it's important to wait until it's in started mode before making any COM calls.

Using SCM

The service can be stopped and started via the service control manager, or via the SCM WinAPI, in order to do so the controlling application must have administrative privileges.

Using COM

When using the COM the controlling application doesn't have to have administrating privileges.

Shutting down

To shut down the proxy you can call the COM method StopProcess

dim dt as new DataController
dt.StopProcess

Starting up

Any COM call will start the service, you need to make sure that you wait until the service is in started state before making any further COM calls, also the COM call that brings up the service may fail due to timeout, so make sure you capture and ignore any error you encounter

dim dt as new DataController

'Bring up the service
dim tb as DataTable
set tb=dt.GetTable(dtApplications)

'Here will be code that waits until the service is in started mode using the SCM WinAPI

API

The API is built somewhat like a database, it has tables and containers (which can be regarded to as tables inside tables) which allows the user to set and receive information.

DataTable

This class represents a table inside the Redirector, it's where all the data is stored.

The class has several important methods to work with data:

Bulk methods

The data structure of bulk data is:

  • For single data table (like Applications, ports, IPs) it will look like this: iexplore.exe, firefox.exe
  • For double data tables (like flags which consists of index and data) it will look like this: flagname, flagvalue

BulkAdd

This methods add data in bulk from the table.

bData - The data to add delimited by comma.

BulkGet

This methods gets data in bulk to the table.

bData - The bulk data received.

BulkErase

This methods erases data in bulk from the table.

bData - The bulk data to be erased.

AddString

This method will add a string to the table, you can add a number as a string, at the end all data is stored as strings.

bString - String to add.

AddLong

This method will add a number to the table.

lData - Number to add.

AddStringIdx

This method will add a string to the table that is build with index and data (like the flags table):

bIndex - Index of the data. bStr - String of the data.

AddLongIdx

This method will add a number to the table that is build with index and data (like the flags table):

bIndex - Index of the data. bStr - String of the data.

Clear

This method clears all data in the table.

Commit

This method commits the data to the table, all changes are not saved to the table until then. (Keep in mind you will also have to save the data to file later in the process using CDataController::Save)

DoesLongExists

This method checks if a number exists in the table:

lData - The number to search.

Return value - 1 for there, 0 for not found.

DoesStringExists

This method checks if a string exists in the table:

bString- The string to search.

Return value - 1 for there, 0 for not found.

EraseLong

This method erases a number entry from the table.

lData - The number to erase.

EraseString

This method erases a string entry from the table.

bString- The string to erase.

GetLong

This method retrieves the numeral data associated with a an index.

bString - Index of the data.

Return value - The data (0 if it's not there)

GetString

This method retrieves the string data associated with a an index.

bString - Index of the data.

Return value - The string data (empty if it's not there)

DataController

This is the main COM class to control the Redirector.

GetTable

This method is used to retreive system tables that control various aspects of the Redirector functionality.

TCP Outgoing tables

  • dtApplication - Applications to intercept.
  • dtPort - Ports to intercept.
  • dtIP - IPs to intercept.
  • dtApplicationInv - Applications to never intercept.
  • dtPortInv - Ports to never intercept.
  • dtIPInv - IPs to never intercept.

UDP Outgoing tables

UDP interception is part of: Komodia's Redirector Advanced Version.

  • dtApplicationUDP - Applications to intercept.
  • dtPortUDP - Ports to intercept.
  • dtIPUDP - IPs to intercept.
  • dtApplicationInvUDP - Applications to never intercept.
  • dtPortInvUDP - Ports to never intercept.
  • dtIPInvUDP - IPs to never intercept.

TCP Incoming tables

TCP Incoming interception is part of: Komodia's Redirector Advanced Version.

  • dtApplicationTCPI - Applications to intercept.
  • dtPortTCPI - Ports to intercept.
  • dtIPTCPI - IPs to intercept.
  • dtApplicationInvTCPI - Applications to never intercept.
  • dtPortInvTCPI - Ports to never intercept.
  • dtIPInvTCPI - IPs to never intercept.

Hard include/exclude

  • dtHardExclude - Hard exclude applications.
  • dtHardInclude - Hard include applications.

Flags

Flags table (dtFlags) is a index/data type table which holds many settings to control the Redirector.

These are the index values:

  • lsprefresh - LSP refresh time, don't change this value without consulting with Komodia first.
  • rdenabled - Redirector enable/disable status.
  • appinv - TCP outgoing applications inversion flag.
  • portinv - TCP outgoing ports inversion flag.
  • ipinv - TCP outgoing IPs inversion flag.
  • appinvudp - UDP outgoing applications inversion flag.
  • portinvudp - UDP outgoing ports inversion flag.
  • ipinvudp - UDP outgoing IPs inversion flag.
  • appinvi - TCP incoming applications inversion flag.
  • portinvi - TCP incoming ports inversion flag.
  • ipinvi - TCP incoming IPs inversion flag.
  • dlltoload - DLL to load file name.
  • disablecache - Disable HTTP caching.
  • httpdisable - Disable HTTP Parser (only if it exists).
  • tcprulesand - When true, sets the rules between the applications, ports, and IPs to logical AND instead of logical OR.
  • processname - When true and HTTP header processing enabled it will add a header to the outgoing request (X-Process-Name) with the name of the process.
  • dllhttponly - When using the DLL framework setting this flag to true will send the DLL only the HTTP methods and not DataBeforeReceive and DataBeforeSend
  • intservices - Inverses the services compile time behavior.
  • pcdebug - Sets debugging print for callbacks.
  • pclog - Enables HTTP Parser traffic logs (only when traffic log is enabled)
  • proxysni - When using HTTP Connect proxy, SDK will try to use SNI instead of IP, this will not work 100% because the way browsers and SNI works.
  • nocom - Disables COM for LSP, LSP will work via offline file only.
  • cdebug - Setting it to 1 will write the classification received into the main log.
  • holdhtml - Setting it to 1 will cause any HTML page to be held and only released when the SDK has the entire page.
  • kcsppenabled - Setting it to 1 will enable per page classification (only for versions that has this module).
  • ddisable - Domains in this flag will not be held by HTTP Parser (you can specify number of domains, and use "," as a delimiter)
  • cdebug - Set this flag to 1 to enable classification debug prints.
  • comdisableredirect - Disable COM redirect on COM framework error.
  • comredirectoncealways - Redirect once, on COM framework error, even if set to disconnect on error is true.
  • SSL Digestor:
    • ssldisable - Disable SSL Digestor.
    • ssldisablecc - Disable handling of SSL client certificates.
    • sslinv - When true the SSL exclusion list will become inverted and only apps in the list will be decrypted.
    • ssldinv - When true the SSL exclusion list will become inverted and only domains in the list will be decrypted.
    • Custom CA: (SDK must be restarted after setting these keys)
      • sslpub - To the path of the public key .pem file.
      • sslprv - To the path of the private key .pem file.
      • sslpsd - To the password of the root CA (it's mandatory).
      • sslforce - The three previous keys only work if the certs inside KomodiaProduct.h don't exist, if there are certs, an override is needed, when sslforce is set to 1, the SDK will use the new certs.

Global proxy

Proxy table (dtProxy) is a index/data type table which holds many settings to control proxy usage of the Redirector (Komodia's Redirector installation guide#Global_proxy_control).

These are the index values:

  • ip - IP of the proxy.
  • port - Port of the proxy.
  • username - Username of the proxy.
  • password - Password of the proxy.
  • type - Type of the proxy, according to this enum:
typedef enum _IProxyType
{
	iptHTTP,
	iptHTTPConnect,
	iptHTTPConnectSSL,
	iptHTTPHybrid,
	iptHTTPHybridSSL,
	iptSocks4,
	iptSocks5,
	iptHTTPSSL,
	iptSocks5TCPUDP,
	iptRedirect,
	iptRedirectBypass,
	iptSSLSubst,
	iptNone
} IProxyType;

Proxy per application

Proxy per application (Komodia's Redirector installation guide#Proxy per application) table is under the table dtProxyApps, and it is composed of an index with the name of the app, and ~ delimited data with the proxy actual data which is: proxy type (integer using the num)~Proxy IP~Proxy port~Username (optional if needed)~Password (optional if needed)

For example a HTTP Hybrid proxy for Internet Explorer line would look like:

Index: iexplore.exe Data: 3~127.0.0.1~8080

Or if we wanted to specify a socks5 with username and password:

Index: iexplore.exe Data: 6~127.0.0.1~1080~admin~adminpass

Clear

This method will reset the Redirector to its default values.

Load

This method will load settings from file.

Text load

Allows to load data from editable mode (without using the API to edit the data):

  • LoadFromText- Will Load the data from a file.
  • LoadFromString- Will Load the data from a string.

Save

This method will save settings to a file.

Text save

Allows to save data in editable mode (without using the API to edit the data):

  • SaveToText - Will save the data to a file.
  • SaveToString - Will save the data to a string.

StopProcess

This method will stop the Redirector process, the process will exit gracefully.

BroadcastChange

This method pushes the Redirector settings immediately, you can read more about it here: Komodia's Redirector user experience guide#Rules_update.

It only effects when rules has been changed, it has no effect when the proxy has been changed.

UpdateLSPNow

This is needed when you update a proxy that contains a UDP proxy, when you switch to or from a UDP proxy, this method will create or terminate the TCP associate.

KillAllConnections

Will terminate all existing connections, the terminate will be sent as soon as there's data on the session, this means that an idle connection will be open until a data will be sent/receive.

This method is good if you want to terminate all existing connections when you switch a proxy.

GetInstaceID

This method gets the instance ID of the Redirector, in case the Redirector was restarted, the instance ID will change, also it gives the ID of the current COM interface (if you are using the COM framework), in case the interface was changed, or there was an error and the interface was removed, this ID will change as well. The format of the ID is GUID and the two IDs are seperated by a comma:

GUID,GUID

SetEnable

This methods changes the Redirector state to normal or bypass (default is normal), when in bypass, traffic that is set to intercepted is going via the Redirector, but isn't processed in any way.

IsEnabled

This methods gives the state of the Redirector, is it normal or bypass.

DownloadFile

HRESULT DownloadFile(BSTR bURL,
		     BSTR bFile,
		     long lTimeout,
		     [out]long* pTimeout,
		     [out,retval]BSTR* pError);

This method will download a file to the hard driver, parameters:

  • bURL - Full URL of the file, including http://
  • bFile - Full path of the file to store
  • lTimeout - Timeout in miliseconds, 0 is no timeout
  • pTimeout - When the function exists, this will contain true if a timeout occurred
  • pError - When the function exists, this will contain the error if an error occurred

IsLSPInstalled

typedef enum _ILSPInstall
{
	iliNo=0,
	iliOKSingle,
	iliOKAnd3rdParty,
	iliOnly3rdParty,
	iliFileMissing,
	ili32bitOS
} ILSPInstall;

HRESULT IsLSPInstalled32([out,retval]ILSPInstall* lResult);
HRESULT IsLSPInstalled64([out,retval]ILSPInstall* lResult);

This method will return the state of the LSP installation:

  • iliNo - LSP is not installed.
  • iliOKSingle - LSP is installed and is single on the stack.
  • iliOKAnd3rdParty - LSP is installed and also a 3rd party.
  • iliOnly3rdParty - Only 3rd party LSP is installed.
  • iliFileMissing - LSP is installed by the DLL itself is missing.
  • ili32bitOS - You called the 64bit method on 32bit OS.

You use IsLSPInstalled32 to get 32bit LSP status (you call this always), and IsLSPInstalled64 to get 64bit LSP status, this is called on 64bit OSs only.

ForceWFPUpdate

When deploying a .ini file from another machine, call this method to make sure the WFP gets the correct settings, the reason is that WFP uses a shadow table, which might be in the .ini from the development machine which will affect WFP update.

Quick samples

All quick samples are written using VB6 syntax.

Adding applications to intercept

'Get the table
dim dt as new DataController
dim tb as DataTable
set tb=dt.GetTable(dtApplications)

'Add the applications
tb.AddString "iexplore.exe"
tb.AddString "firefox.exe"

'Commit the data
tb.Commit

'Save data to file
dt.Save

Setting intercepting of all apps

You need to make sure that the app list in the outgoing TCP is clear.

'Get the table
dim dt as new DataController
dim tb as DataTable
set tb=dt.GetTable(dtFlags)

'Inversing the flag
tb.AddStringIdx("appinv","1")

'Commit the data
tb.Commit

'Save data to file
dt.Save

Adding ports to intercept

'Get the table
dim dt as new DataController
dim tb as DataTable
set tb=dt.GetTable(dtPorts)

'Add the applications
tb.AddString "443"
tb.AddString "80"

'Commit the data
tb.Commit

'Save data to file
dt.Save

Proxy settings

Setting a global proxy server

'Get the table
dim dt as new DataController
dim tb as DataTable
set tb=dt.GetTable(dtProxy)

'Add the proxy 
tb.AddStringIdx "ip","127.0.0.1"
tb.AddStringIdx "port","8080"
tb.AddStringIdx "type",3

'Optional username and password
tb.AddStringIdxPreserveCase "username","admin"
tb.AddStringIdxPreserveCase "password","pass"

'Commit the data
tb.Commit

'Save data to file
dt.Save

Clearing the global proxy settings

'Get the table
dim dt as new DataController
dim tb as DataTable
set tb=dt.GetTable(dtProxy)

'Add the proxy 
tb.Clear

'Commit the data
tb.Commit

'Save data to file
dt.Save

Setting an application proxy server

This will set a hybrid HTTP Server for Internet Explorer.

'Get the table
dim dt as new DataController
dim tb as DataTable
set tb=dt.GetTable(dtProxyApps)

'Add the proxy 
tb.AddStringIdxPreserveCase "iexplore.exe","3~127.0.0.1~8080"

'Commit the data
tb.Commit

'Save data to file
dt.Save

Removing an application proxy server

This will remove entry for Internet Explorer.

'Get the table
dim dt as new DataController
dim tb as DataTable
set tb=dt.GetTable(dtProxyApps)

'Add the proxy 
tb.EraseString "iexplore.exe"

'Commit the data
tb.Commit

'Save data to file
dt.Save

Clearing all application proxies

'Get the table
dim dt as new DataController
dim tb as DataTable
set tb=dt.GetTable(dtProxyApps)

'Add the proxy 
tb.Clear

'Commit the data
tb.Commit

'Save data to file
dt.Save

Getting the value of a specific application proxy

'Get the table
dim dt as new DataController
dim tb as DataTable
set tb=dt.GetTable(dtProxyApps)

'Check if we have a record for Internet Explorer
if tb.DoesStringExists("iexplore.exe") then
    dim ProxyData as string
    ProxyData=tb.GetString("iexplore.exe")
endif

Setting/Getting flag value

'Get the table
dim dt as new DataController
dim tb as DataTable
set tb=dt.GetTable(dtFlags)

'Inverse the applications status
if tb.GetString("appinv")="1"
    tb.AddStringIdx("appinv","0")
else
    tb.AddStringIdx("appinv","1")
end if

'Commit the data
tb.Commit

'Save data to file
dt.Save

Setting a custom variable

'Get the table
dim dt as new DataController
dim tb as DataTable
set tb=dt.GetTable(dtFlags)

'Set the variable
tb.AddStringIdx "myvar","mydata"

'Commit the data
tb.Commit

'Save data to file
dt.Save

Getting a custom variable

'Get the table
dim dt as new DataController
dim tb as DataTable
set tb=dt.GetTable(dtFlags)

'Set the variable
msgbox tb.GetString("myvar")

Setting a DLL to load

Settings a DLL to load is just setting a variable in the flags (the variable is: "dlltoload")

'Get the table
dim dt as new DataController
dim tb as DataTable
set tb=dt.GetTable(dtFlags)

'Set the variable
tb.AddStringIdx "dlltoload","full dll path" 'Full DLL path can look like this: c:\program files\prog\dll.dll
'You can also use system variables: %programfiles%\prog\dll.dll

'Commit the data
tb.Commit

'Save data to file
dt.Save

HTTP header manipulation

Header manipulation is under a container, which has two tables and some flags.

Cache control

To enable/disable clearing the cache:

Dim dt As DataTable
Set dt = dc.GetTable(dtFlags)
    
'This is a checkbox in the form
If DisableCaching = Checked Then
    dt.AddLongIdx "disablecache", 1
Else
    dt.AddLongIdx "disablecache", 0
End If
        
'Save it
dt.Commit

Header control

To enable/disable the header processing:

Dim dt As DataTable
Set dt = dc.GetTable(dtFlags)
    
'This is a checkbox in the form
If DisableCaching = Checked Then
    dt.AddLongIdx "filterhttp", 1
Else
    dt.AddLongIdx "filterhttp", 0
End If
        
'Save it
dt.Commit

Managing the header tables

The header processing tables are under the container ctHTTPFilter and they are named: filter and custom

Adding field to modify/delete

'Get the DC
Set dc = GetDataController
    
'Get the manager
Dim Mgr As DataTableHolder
Set Mgr = dc.GetContainer(ctHTTPFilter)
    
'Get the table
Dim FilterTbl As DataTable
Set FilterTbl = Mgr.GetTable("filter")

'Add a header to change (for example user-agent)
FilterTbl.AddStringIdx "user-agent","some value"

'Add a header to delete
FilterTbl.AddStringIdx "refer"

'Save changes
FilterTbl.Commit
Mgr.Commit
dc.Save

Adding a custom field

'Get the DC
Set dc = GetDataController
    
'Get the manager
Dim Mgr As DataTableHolder
Set Mgr = dc.GetContainer(ctHTTPFilter)
    
'Get the table
Dim FilterTbl As DataTable
Set FilterTbl = Mgr.GetTable("custom")

'Add a header to change (for example user-agent)
FilterTbl.AddStringIdx "X-customheader","some value"

'Save changes
FilterTbl.Commit
Mgr.Commit
dc.Save

SSH connect

Dim sh As New SSHController
sh.SetSSHLogFile TextLog
If sh.CreateSSHSession(SSHText, TimeoutText) <> 0 Then
    MsgBox "Failed to create SSH"
Else
    MsgBox "SSH created"
End If

Black/white list module

Enabling the black/white list module

'Set it
Dim dc As DataController
Set dc = GetDataController
    
'Get the flags
Dim tbl As DataTable
Set tbl = dc.GetTable(dtFlags)
    
'Get the flag
Dim lParental As Long
lParental = tbl.GetLong("parentalcontrol")
    
'Set it
tbl.AddLongIdx "parentalcontrol", 1
    
'Save it
tbl.Commit

Disabling the black/white list module

'Set it
Dim dc As DataController
Set dc = GetDataController
    
'Get the flags
Dim tbl As DataTable
Set tbl = dc.GetTable(dtFlags)
    
'Get the flag
Dim lParental As Long
lParental = tbl.GetLong("parentalcontrol")
    
'Set it
tbl.AddLongIdx "parentalcontrol", 0
    
'Save it
tbl.Commit

Setting the module to whitelist mode

'Get the type
Dim dc As DataController
Set dc = GetDataController
        
'First get the container
Dim tbh As DataTableHolder
Set tbh = dc.GetContainer(ctParentalControl)
        
'Get the table
Dim tbl As DataTable
Set tbl = tbh.GetTable("flags")
        
tbl.AddLongIdx "parentalcontrolwhitelist", 1
        
'This is where any other site will be redirected to (must not include http:// or https://)
tbl.AddStringIdx "whitelistredirect", "www.siteredirect.com"
        
tbl.Commit
tbh.Commit

Adding exact domains to the list (black or white)

'Get the DC
Set dc = GetDataController
    
'Get the manager
Dim Mgr As DataTableHolder
Set Mgr = dc.GetContainer(ctParentalControl)
    
'Get the table
Dim Tbl As DataTable
Set Tbl = Mgr.GetTable("exactdomainblacklist")

'Add a domain
Tbl.AddStringIdx "www.block.com"

'Save changes
Tbl .Commit
Mgr.Commit

Adding partial domains to the list (black or white)

'Get the DC
Set dc = GetDataController
    
'Get the manager
Dim Mgr As DataTableHolder
Set Mgr = dc.GetContainer(ctParentalControl)
    
'Get the table
Dim Tbl As DataTable
Set Tbl = Mgr.GetTable("partialdomainblacklist")

'Add a domain
Tbl.AddStringIdx "www.block.com"

'Save changes
Tbl .Commit
Mgr.Commit

Setting a custom root CA for validation

  • The file is a pem file with one or more root CA.
  • The SDK must be restarted for settings to take effect.
'Get the table
dim dt as new DataController
dim tb as DataTable
set tb=dt.GetTable(dtFlags)

'Set the variable
tb.AddStringIdx "sslca","c:\pathtoca.pem"

'Commit the data
tb.Commit

'Save data to file
dt.Save