Throttling

Throttling feature

Requests that presented below are uses for configure firewall:

RemoveProcess - removes process from throttling list

var throttlingRequest = new ThrottlingRequest
{
    RemoveProcess = new List<RemoveProcessRequest>
    {
        new RemoveProcessRequest { Process = "processName"},
    },
} 

RemoveAllProcesses - removes all processes from throttling list

var throttlingRequest = new ThrottlingRequest
{
    RemoveAllProcesses = new EmptyRequest(),
} 

ClearSpeedLimits - clears speed limits

var throttlingRequest = new ThrottlingRequest
{
    ClearSpeedLimits = new List<ClearSpeedLimitsRequest>
    {
        new ClearSpeedLimitsRequest { SpeedLimitId = id},
    },
} 

RemoveSpeedLimit - removes speed limits

var throttlingRequest = new ThrottlingRequest
{
    RemoveSpeedLimit= new List<RemoveSpeedLimitRequest>
    {
        new RemoveSpeedLimitRequest{ SpeedLimitId = id},
    },
} 

RemoveAllSpeedLimits - removes speed limits

var throttlingRequest = new ThrottlingRequest
{
    RemoveSpeedLimit = new EmptyRequest(),
} 

DefaultSpeedLimit - sets the default speed limit

var throttlingRequest = new ThrottlingRequest
{
    DefaultSpeedLimit = new DefaultSpeedLimitRequest
    {
        DownloadSpeed = RxSpeedValue,
        UploadSpeed = TxSpeedValue,
    },
} 

SetSpeedLimit - sets the speed limit

var throttlingRequest = new ThrottlingRequest
{
    DefaultSpeedLimit =  new List<SetSpeedLimitRequest>
    {
        DownloadSpeed = RxSpeedValue,
        UploadSpeed = TxSpeedValue,
        SpeedLimitId = speedLimitId,
    },
} 

AddProcesses - sets the process list

var throttlingRequest = new ThrottlingRequest
{
    AddProcesses =  new List<AddProcessesRequest>
    {
        Processes = new List { "processName" },
        LimitId = speedLimitId,
    },
} 

Enable - enables throttling

var throttlingRequest = new ThrottlingRequest
{
    Enable = new EmptyRequest(),
} 

Disable - disables throttling

var throttlingRequest = new ThrottlingRequest
{
    Disable = new EmptyRequest(),
} 

ConfigureThrottling

Sends throttling configuration to the service. Important: Throttling feature can be applied only thru the connected tunnel.

Example:
    var sdk = new SDK();
    var speedReq = new List<Core.Model.SpeedLimit>().Select(p => new SetSpeedLimitRequest()
    {
        SpeedLimitId = p.ClientId,
        DownloadSpeed = p.In,
        UploadSpeed = p.Out,
    }).ToList();
    
    var procReq = new AddProcessesRequest()
    {
        Processes = new List<Core.Model.SpeedLimit>()
        .SelectMany(p => p.ProcessesList.Select(p2 => new ProcessLimit() { SpeedLimitId = p.ClientId, Process = p2.ProcessName })).ToList(),
    };
    
    var throttlingRequest = new ThrottlingRequest()
    {
        AddProcesses = procReq,
        SetSpeedLimit = speedReq,
        DefaultSpeedLimit = new DefaultSpeedLimitRequest() { DownloadSpeed = 100, UploadSpeed = 100 },
        RemoveAllProcesses = new Core.RPC.EmptyRequest(),
        RemoveSpeedLimitProcesses = new RemoveSpeedLimitProcessesRequest(),
        Enable = new Core.RPC.EmptyRequest(),
        Disable = null,
    };
    
    var configureThrottlingResponse = sdk.ConfigureThrottling(throttlingRequest);
    Console.WriteLine(configureThrottlingResponse.AddProcesses);

Last updated