Kurlyk
Loading...
Searching...
No Matches
kurlyk::WebSocketConfig Class Reference

Configuration parameters for establishing and managing WebSocket connections. More...

#include <WebSocketConfig.hpp>

Classes

struct  RateLimitData
 Defines rate limit parameters. More...
 

Public Member Functions

void set_url (const std::string &host, const std::string &path, const std::string &query="")
 Sets the WebSocket server URL with optional query parameters.
 
void set_url (const std::string &url, const QueryParams &query)
 Sets the WebSocket server URL with specified query parameters.
 
void set_accept_encoding (bool identity=false, bool deflate=false, bool gzip=false, bool brotli=false)
 Sets the Accept-Encoding header with specified encodings.
 
void set_proxy (const std::string &ip, int port)
 Sets the proxy server address.
 
void set_proxy (const std::string &ip, int port, ProxyType type)
 Sets the proxy server address.
 
void set_proxy_server (const std::string &server)
 Sets the proxy server address.
 
void set_proxy_auth (const std::string &auth)
 Sets the proxy authentication credentials.
 
void set_proxy_type (ProxyType type)
 Sets the proxy type.
 
void set_proxy (const std::string &ip, int port, const std::string &username, const std::string &password, ProxyType type=ProxyType::PROXY_HTTP)
 Sets the proxy server address with authentication.
 
void set_proxy_auth (const std::string &username, const std::string &password)
 Configures proxy authentication credentials.
 
void set_reconnect (bool reconnect, long reconnect_attempts=0, long reconnect_delay=0)
 Configures reconnection behavior.
 
void set_user_agent (const std::string &user_agent)
 Sets the User-Agent header.
 
void set_accept_language (const std::string &accept_language)
 Sets the Accept-Language header.
 
void set_cookie (const std::string &cookie)
 Sets the cookie data.
 
void set_idle_timeout (long idle_timeout)
 Configures the idle timeout for the WebSocket connection.
 
void set_request_timeout (long request_timeout)
 Sets the timeout for WebSocket requests.
 
void set_ca_file (const std::string &ca_file)
 Sets the path to the CA certificate file.
 
void set_ca_file (bool verify_cert, const std::string &ca_file)
 Sets certificate verification and sets the CA certificate file.
 
void set_verify_cert (bool verify_cert)
 Sets whether to verify the server’s certificate.
 
long add_rate_limit (long requests_per_period, long period_ms)
 Adds a rate limit configuration to control the frequency of WebSocket messages.
 
long add_rate_limit_rpm (long requests_per_minute)
 Adds a rate limit based on Requests Per Minute (RPM).
 
long add_rate_limit_rps (long requests_per_second)
 Adds a rate limit based on Requests Per Second (RPS).
 

Public Attributes

Headers headers
 HTTP headers included in the WebSocket connection request.
 
std::string url
 URL of the WebSocket server.
 
std::string user_agent
 User-Agent header.
 
std::string accept_encoding
 Accept-Encoding header.
 
std::string cookie
 Cookie data as a string.
 
std::vector< std::string > protocols
 List of subprotocols for the Sec-WebSocket-Protocol header.
 
std::string cert_file
 Path to the client certificate file.
 
std::string key_file
 Path to the private key file corresponding to the client certificate.
 
std::string ca_file
 Path to the Root CA certificate file.
 
std::string proxy_server
 Proxy address in <ip:port> format.
 
std::string proxy_auth
 Proxy authentication in <username:password> format.
 
ProxyType proxy_type = ProxyType::PROXY_HTTP
 Proxy type (e.g., HTTP, SOCKS5).
 
long request_timeout = 20
 Timeout for WebSocket requests in seconds (0 means no timeout).
 
long idle_timeout = 0
 Maximum idle time for the WebSocket connection in seconds (0 means no timeout).
 
long reconnect_delay = 5
 Delay in seconds between reconnection attempts.
 
long reconnect_attempts = 0
 Number of reconnection attempts (0 means infinite attempts).
 
bool reconnect = true
 Enables automatic reconnection if true.
 
bool verify_cert = true
 If true, verifies the server’s certificate and hostname according to RFC 2818.
 
std::vector< RateLimitDatarate_limits
 List of rate limits applied to WebSocket messages.
 

Detailed Description

Configuration parameters for establishing and managing WebSocket connections.

Definition at line 12 of file WebSocketConfig.hpp.

Member Function Documentation

◆ add_rate_limit()

long kurlyk::WebSocketConfig::add_rate_limit ( long requests_per_period,
long period_ms )
inline

Adds a rate limit configuration to control the frequency of WebSocket messages.

The first rate limit added will serve as the primary rate limit, applying to all WebSocket requests by default. Additional rate limits can be added for specific types of requests or contexts as needed.

Parameters
requests_per_periodThe maximum number of messages allowed within the specified period.
period_msThe time period in milliseconds during which the request limit applies.
Returns
The index of the added rate limit configuration.

Definition at line 208 of file WebSocketConfig.hpp.

◆ add_rate_limit_rpm()

long kurlyk::WebSocketConfig::add_rate_limit_rpm ( long requests_per_minute)
inline

Adds a rate limit based on Requests Per Minute (RPM).

Parameters
requests_per_minuteMaximum number of requests allowed per minute.
Returns
The index of the added rate limit configuration.

Definition at line 216 of file WebSocketConfig.hpp.

◆ add_rate_limit_rps()

long kurlyk::WebSocketConfig::add_rate_limit_rps ( long requests_per_second)
inline

Adds a rate limit based on Requests Per Second (RPS).

Parameters
requests_per_secondMaximum number of requests allowed per second.
Returns
The index of the added rate limit configuration.

Definition at line 224 of file WebSocketConfig.hpp.

◆ set_accept_encoding()

void kurlyk::WebSocketConfig::set_accept_encoding ( bool identity = false,
bool deflate = false,
bool gzip = false,
bool brotli = false )
inline

Sets the Accept-Encoding header with specified encodings.

Parameters
identityEnables identity encoding.
deflateEnables deflate encoding.
gzipEnables gzip encoding.
brotliEnables brotli encoding.

Definition at line 72 of file WebSocketConfig.hpp.

◆ set_accept_language()

void kurlyk::WebSocketConfig::set_accept_language ( const std::string & accept_language)
inline

Sets the Accept-Language header.

Parameters
accept_languageAccept-Language string.

Definition at line 157 of file WebSocketConfig.hpp.

◆ set_ca_file() [1/2]

void kurlyk::WebSocketConfig::set_ca_file ( bool verify_cert,
const std::string & ca_file )
inline

Sets certificate verification and sets the CA certificate file.

Parameters
verify_certIf true, enables server certificate verification.
ca_filePath to the CA certificate file.

Definition at line 188 of file WebSocketConfig.hpp.

◆ set_ca_file() [2/2]

void kurlyk::WebSocketConfig::set_ca_file ( const std::string & ca_file)
inline

Sets the path to the CA certificate file.

Parameters
ca_filePath to the CA certificate file.

Definition at line 181 of file WebSocketConfig.hpp.

◆ set_cookie()

void kurlyk::WebSocketConfig::set_cookie ( const std::string & cookie)
inline

Sets the cookie data.

Parameters
cookieCookie data string.

Definition at line 163 of file WebSocketConfig.hpp.

◆ set_idle_timeout()

void kurlyk::WebSocketConfig::set_idle_timeout ( long idle_timeout)
inline

Configures the idle timeout for the WebSocket connection.

Parameters
idle_timeoutIdle timeout in seconds (0 means no timeout).

Definition at line 169 of file WebSocketConfig.hpp.

◆ set_proxy() [1/3]

void kurlyk::WebSocketConfig::set_proxy ( const std::string & ip,
int port )
inline

Sets the proxy server address.

Parameters
ipProxy server IP address.
portProxy server port.

Definition at line 84 of file WebSocketConfig.hpp.

◆ set_proxy() [2/3]

void kurlyk::WebSocketConfig::set_proxy ( const std::string & ip,
int port,
const std::string & username,
const std::string & password,
ProxyType type = ProxyType::PROXY_HTTP )
inline

Sets the proxy server address with authentication.

Parameters
ipProxy server IP address.
portProxy server port.
usernameProxy username.
passwordProxy password.
typeType of proxy (default is HTTP).

Definition at line 121 of file WebSocketConfig.hpp.

◆ set_proxy() [3/3]

void kurlyk::WebSocketConfig::set_proxy ( const std::string & ip,
int port,
ProxyType type )
inline

Sets the proxy server address.

Parameters
ipProxy server IP address.
portProxy server port.
typeType of proxy.

Definition at line 92 of file WebSocketConfig.hpp.

◆ set_proxy_auth() [1/2]

void kurlyk::WebSocketConfig::set_proxy_auth ( const std::string & auth)
inline

Sets the proxy authentication credentials.

Parameters
authProxy authentication in <username:password> format.

Definition at line 105 of file WebSocketConfig.hpp.

◆ set_proxy_auth() [2/2]

void kurlyk::WebSocketConfig::set_proxy_auth ( const std::string & username,
const std::string & password )
inline

Configures proxy authentication credentials.

Parameters
usernameProxy username.
passwordProxy password.

Definition at line 135 of file WebSocketConfig.hpp.

◆ set_proxy_server()

void kurlyk::WebSocketConfig::set_proxy_server ( const std::string & server)
inline

Sets the proxy server address.

Parameters
serverProxy address in <ip:port> format.

Definition at line 99 of file WebSocketConfig.hpp.

◆ set_proxy_type()

void kurlyk::WebSocketConfig::set_proxy_type ( ProxyType type)
inline

Sets the proxy type.

Parameters
typeType of proxy.

Definition at line 111 of file WebSocketConfig.hpp.

◆ set_reconnect()

void kurlyk::WebSocketConfig::set_reconnect ( bool reconnect,
long reconnect_attempts = 0,
long reconnect_delay = 0 )
inline

Configures reconnection behavior.

Parameters
reconnectEnables automatic reconnection.
reconnect_attemptsNumber of reconnection attempts (0 means infinite attempts).
reconnect_delayDelay in seconds between reconnection attempts.

Definition at line 143 of file WebSocketConfig.hpp.

◆ set_request_timeout()

void kurlyk::WebSocketConfig::set_request_timeout ( long request_timeout)
inline

Sets the timeout for WebSocket requests.

Parameters
request_timeoutRequest timeout in seconds (0 means no timeout).

Definition at line 175 of file WebSocketConfig.hpp.

◆ set_url() [1/2]

void kurlyk::WebSocketConfig::set_url ( const std::string & host,
const std::string & path,
const std::string & query = "" )
inline

Sets the WebSocket server URL with optional query parameters.

Parameters
hostHostname or IP address.
pathPath for the request.
queryOptional query parameters.

Definition at line 49 of file WebSocketConfig.hpp.

◆ set_url() [2/2]

void kurlyk::WebSocketConfig::set_url ( const std::string & url,
const QueryParams & query )
inline

Sets the WebSocket server URL with specified query parameters.

Parameters
urlFull URL of the server.
queryQuery parameters as a dictionary.

Definition at line 63 of file WebSocketConfig.hpp.

◆ set_user_agent()

void kurlyk::WebSocketConfig::set_user_agent ( const std::string & user_agent)
inline

Sets the User-Agent header.

Parameters
user_agentUser-Agent string.

Definition at line 151 of file WebSocketConfig.hpp.

◆ set_verify_cert()

void kurlyk::WebSocketConfig::set_verify_cert ( bool verify_cert)
inline

Sets whether to verify the server’s certificate.

Parameters
verify_certIf true, enables server certificate verification.

Definition at line 195 of file WebSocketConfig.hpp.

Member Data Documentation

◆ accept_encoding

std::string kurlyk::WebSocketConfig::accept_encoding

Accept-Encoding header.

Definition at line 17 of file WebSocketConfig.hpp.

◆ ca_file

std::string kurlyk::WebSocketConfig::ca_file

Path to the Root CA certificate file.

Definition at line 22 of file WebSocketConfig.hpp.

◆ cert_file

std::string kurlyk::WebSocketConfig::cert_file

Path to the client certificate file.

Definition at line 20 of file WebSocketConfig.hpp.

◆ cookie

std::string kurlyk::WebSocketConfig::cookie

Cookie data as a string.

Definition at line 18 of file WebSocketConfig.hpp.

◆ headers

Headers kurlyk::WebSocketConfig::headers

HTTP headers included in the WebSocket connection request.

Definition at line 14 of file WebSocketConfig.hpp.

◆ idle_timeout

long kurlyk::WebSocketConfig::idle_timeout = 0

Maximum idle time for the WebSocket connection in seconds (0 means no timeout).

Definition at line 27 of file WebSocketConfig.hpp.

◆ key_file

std::string kurlyk::WebSocketConfig::key_file

Path to the private key file corresponding to the client certificate.

Definition at line 21 of file WebSocketConfig.hpp.

◆ protocols

std::vector<std::string> kurlyk::WebSocketConfig::protocols

List of subprotocols for the Sec-WebSocket-Protocol header.

Definition at line 19 of file WebSocketConfig.hpp.

◆ proxy_auth

std::string kurlyk::WebSocketConfig::proxy_auth

Proxy authentication in <username:password> format.

Definition at line 24 of file WebSocketConfig.hpp.

◆ proxy_server

std::string kurlyk::WebSocketConfig::proxy_server

Proxy address in <ip:port> format.

Definition at line 23 of file WebSocketConfig.hpp.

◆ proxy_type

ProxyType kurlyk::WebSocketConfig::proxy_type = ProxyType::PROXY_HTTP

Proxy type (e.g., HTTP, SOCKS5).

Definition at line 25 of file WebSocketConfig.hpp.

◆ rate_limits

std::vector<RateLimitData> kurlyk::WebSocketConfig::rate_limits

List of rate limits applied to WebSocket messages.

Definition at line 43 of file WebSocketConfig.hpp.

◆ reconnect

bool kurlyk::WebSocketConfig::reconnect = true

Enables automatic reconnection if true.

Definition at line 30 of file WebSocketConfig.hpp.

◆ reconnect_attempts

long kurlyk::WebSocketConfig::reconnect_attempts = 0

Number of reconnection attempts (0 means infinite attempts).

Definition at line 29 of file WebSocketConfig.hpp.

◆ reconnect_delay

long kurlyk::WebSocketConfig::reconnect_delay = 5

Delay in seconds between reconnection attempts.

Definition at line 28 of file WebSocketConfig.hpp.

◆ request_timeout

long kurlyk::WebSocketConfig::request_timeout = 20

Timeout for WebSocket requests in seconds (0 means no timeout).

Definition at line 26 of file WebSocketConfig.hpp.

◆ url

std::string kurlyk::WebSocketConfig::url

URL of the WebSocket server.

Definition at line 15 of file WebSocketConfig.hpp.

◆ user_agent

std::string kurlyk::WebSocketConfig::user_agent

User-Agent header.

Definition at line 16 of file WebSocketConfig.hpp.

◆ verify_cert

bool kurlyk::WebSocketConfig::verify_cert = true

If true, verifies the server’s certificate and hostname according to RFC 2818.

Definition at line 31 of file WebSocketConfig.hpp.


The documentation for this class was generated from the following file: