bwi/v2.3.0 #29
@ -42,13 +42,6 @@ class WebSocket {
|
||||
|
||||
RublonEventData * currentEvent{nullptr};
|
||||
std::pmr::string proxyUrl{};
|
||||
|
||||
// constexpr static const struct lws_protocol_vhost_options pvo = {
|
||||
// NULL, /* "next" pvo linked-list /
|
||||
// &pvo_proxy_uri, / "child" pvo linked-list /
|
||||
// "push_protocol", / protocol name we belong to on this vhost /
|
||||
// "" / ignored */
|
||||
// };
|
||||
|
||||
public:
|
||||
WebSocket(const Configuration & config) : _config{config}, urlv{_config.get().apiServer}, proxyUrl{_config.get().apiServer.get_allocator()} {
|
||||
@ -70,7 +63,11 @@ class WebSocket {
|
||||
log(rlevel, "libwesockets: %s", line);
|
||||
};
|
||||
|
||||
lws_set_log_level(LLL_ERR | LLL_WARN | LLL_NOTICE | LLL_INFO | LLL_DEBUG | LLL_HEADER, lws_log_emit);
|
||||
if(_config.get().logging) {
|
||||
lws_set_log_level(LLL_ERR | LLL_WARN | LLL_NOTICE | LLL_INFO | LLL_DEBUG | LLL_HEADER, lws_log_emit);
|
||||
} else {
|
||||
lws_set_log_level(LLL_ERR | LLL_WARN, lws_log_emit);
|
||||
}
|
||||
|
||||
memset(&info, 0, sizeof(info));
|
||||
memset(&ccinfo, 0, sizeof(ccinfo));
|
||||
@ -78,15 +75,15 @@ class WebSocket {
|
||||
info.port = CONTEXT_PORT_NO_LISTEN;
|
||||
info.protocols = protocols;
|
||||
info.options = LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT;
|
||||
|
||||
|
||||
if(cfg.proxyEnabled && (cfg.proxyType == "http" || cfg.proxyType == "https")) {
|
||||
assert(cfg.proxyType.has_value());
|
||||
assert(cfg.proxyHost.has_value());
|
||||
log(LogLevel::Debug, "WebSocket using proxy");
|
||||
|
||||
|
||||
// "username:password\@server:port"
|
||||
proxyUrl.reserve(conservative_estimate(cfg.proxyUsername, cfg.proxyPass, cfg.proxyHost) + 10);
|
||||
if(cfg.proxyAuthRequired) {
|
||||
proxyUrl.reserve(conservative_estimate(cfg.proxyUsername, cfg.proxyPass, cfg.proxyHost) + 10);
|
||||
proxyUrl += *cfg.proxyUsername;
|
||||
proxyUrl += ":";
|
||||
proxyUrl += *cfg.proxyPass;
|
||||
@ -96,9 +93,9 @@ class WebSocket {
|
||||
proxyUrl += *cfg.proxyHost;
|
||||
log(LogLevel::Debug, "WebSocket proxy %s", proxyUrl.c_str());
|
||||
info.http_proxy_address = proxyUrl.c_str();
|
||||
info.http_proxy_port = config.proxyPort.value_or(8080);
|
||||
info.http_proxy_port = config.proxyPort.value_or(8080);
|
||||
}
|
||||
|
||||
|
||||
context = lws_create_context(&info);
|
||||
|
||||
const std::string_view prefix = "https://";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user