![]() |
Kurlyk
|
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< RateLimitData > | rate_limits |
List of rate limits applied to WebSocket messages. | |
Configuration parameters for establishing and managing WebSocket connections.
Definition at line 12 of file WebSocketConfig.hpp.
|
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.
requests_per_period | The maximum number of messages allowed within the specified period. |
period_ms | The time period in milliseconds during which the request limit applies. |
Definition at line 208 of file WebSocketConfig.hpp.
|
inline |
Adds a rate limit based on Requests Per Minute (RPM).
requests_per_minute | Maximum number of requests allowed per minute. |
Definition at line 216 of file WebSocketConfig.hpp.
|
inline |
Adds a rate limit based on Requests Per Second (RPS).
requests_per_second | Maximum number of requests allowed per second. |
Definition at line 224 of file WebSocketConfig.hpp.
|
inline |
Sets the Accept-Encoding header with specified encodings.
identity | Enables identity encoding. |
deflate | Enables deflate encoding. |
gzip | Enables gzip encoding. |
brotli | Enables brotli encoding. |
Definition at line 72 of file WebSocketConfig.hpp.
|
inline |
Sets the Accept-Language header.
accept_language | Accept-Language string. |
Definition at line 157 of file WebSocketConfig.hpp.
|
inline |
Sets certificate verification and sets the CA certificate file.
verify_cert | If true, enables server certificate verification. |
ca_file | Path to the CA certificate file. |
Definition at line 188 of file WebSocketConfig.hpp.
|
inline |
Sets the path to the CA certificate file.
ca_file | Path to the CA certificate file. |
Definition at line 181 of file WebSocketConfig.hpp.
|
inline |
Sets the cookie data.
cookie | Cookie data string. |
Definition at line 163 of file WebSocketConfig.hpp.
|
inline |
Configures the idle timeout for the WebSocket connection.
idle_timeout | Idle timeout in seconds (0 means no timeout). |
Definition at line 169 of file WebSocketConfig.hpp.
|
inline |
Sets the proxy server address.
ip | Proxy server IP address. |
port | Proxy server port. |
Definition at line 84 of file WebSocketConfig.hpp.
|
inline |
Sets the proxy server address with authentication.
ip | Proxy server IP address. |
port | Proxy server port. |
username | Proxy username. |
password | Proxy password. |
type | Type of proxy (default is HTTP). |
Definition at line 121 of file WebSocketConfig.hpp.
|
inline |
Sets the proxy server address.
ip | Proxy server IP address. |
port | Proxy server port. |
type | Type of proxy. |
Definition at line 92 of file WebSocketConfig.hpp.
|
inline |
Sets the proxy authentication credentials.
auth | Proxy authentication in <username:password> format. |
Definition at line 105 of file WebSocketConfig.hpp.
|
inline |
Configures proxy authentication credentials.
username | Proxy username. |
password | Proxy password. |
Definition at line 135 of file WebSocketConfig.hpp.
|
inline |
Sets the proxy server address.
server | Proxy address in <ip:port> format. |
Definition at line 99 of file WebSocketConfig.hpp.
|
inline |
Sets the proxy type.
type | Type of proxy. |
Definition at line 111 of file WebSocketConfig.hpp.
|
inline |
Configures reconnection behavior.
reconnect | Enables automatic reconnection. |
reconnect_attempts | Number of reconnection attempts (0 means infinite attempts). |
reconnect_delay | Delay in seconds between reconnection attempts. |
Definition at line 143 of file WebSocketConfig.hpp.
|
inline |
Sets the timeout for WebSocket requests.
request_timeout | Request timeout in seconds (0 means no timeout). |
Definition at line 175 of file WebSocketConfig.hpp.
|
inline |
Sets the WebSocket server URL with optional query parameters.
host | Hostname or IP address. |
path | Path for the request. |
query | Optional query parameters. |
Definition at line 49 of file WebSocketConfig.hpp.
|
inline |
Sets the WebSocket server URL with specified query parameters.
url | Full URL of the server. |
query | Query parameters as a dictionary. |
Definition at line 63 of file WebSocketConfig.hpp.
|
inline |
Sets the User-Agent header.
user_agent | User-Agent string. |
Definition at line 151 of file WebSocketConfig.hpp.
|
inline |
Sets whether to verify the server’s certificate.
verify_cert | If true, enables server certificate verification. |
Definition at line 195 of file WebSocketConfig.hpp.
std::string kurlyk::WebSocketConfig::accept_encoding |
Accept-Encoding header.
Definition at line 17 of file WebSocketConfig.hpp.
std::string kurlyk::WebSocketConfig::ca_file |
Path to the Root CA certificate file.
Definition at line 22 of file WebSocketConfig.hpp.
std::string kurlyk::WebSocketConfig::cert_file |
Path to the client certificate file.
Definition at line 20 of file WebSocketConfig.hpp.
std::string kurlyk::WebSocketConfig::cookie |
Cookie data as a string.
Definition at line 18 of file WebSocketConfig.hpp.
Headers kurlyk::WebSocketConfig::headers |
HTTP headers included in the WebSocket connection request.
Definition at line 14 of file WebSocketConfig.hpp.
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.
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.
std::vector<std::string> kurlyk::WebSocketConfig::protocols |
List of subprotocols for the Sec-WebSocket-Protocol header.
Definition at line 19 of file WebSocketConfig.hpp.
std::string kurlyk::WebSocketConfig::proxy_auth |
Proxy authentication in <username:password> format.
Definition at line 24 of file WebSocketConfig.hpp.
std::string kurlyk::WebSocketConfig::proxy_server |
Proxy address in <ip:port> format.
Definition at line 23 of file WebSocketConfig.hpp.
ProxyType kurlyk::WebSocketConfig::proxy_type = ProxyType::PROXY_HTTP |
Proxy type (e.g., HTTP, SOCKS5).
Definition at line 25 of file WebSocketConfig.hpp.
std::vector<RateLimitData> kurlyk::WebSocketConfig::rate_limits |
List of rate limits applied to WebSocket messages.
Definition at line 43 of file WebSocketConfig.hpp.
bool kurlyk::WebSocketConfig::reconnect = true |
Enables automatic reconnection if true.
Definition at line 30 of file WebSocketConfig.hpp.
long kurlyk::WebSocketConfig::reconnect_attempts = 0 |
Number of reconnection attempts (0 means infinite attempts).
Definition at line 29 of file WebSocketConfig.hpp.
long kurlyk::WebSocketConfig::reconnect_delay = 5 |
Delay in seconds between reconnection attempts.
Definition at line 28 of file WebSocketConfig.hpp.
long kurlyk::WebSocketConfig::request_timeout = 20 |
Timeout for WebSocket requests in seconds (0 means no timeout).
Definition at line 26 of file WebSocketConfig.hpp.
std::string kurlyk::WebSocketConfig::url |
URL of the WebSocket server.
Definition at line 15 of file WebSocketConfig.hpp.
std::string kurlyk::WebSocketConfig::user_agent |
User-Agent header.
Definition at line 16 of file WebSocketConfig.hpp.
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.