mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
debloat: remove things from being built by default that should be conditional
This commit is contained in:
parent
c36a1e8ed0
commit
ae69bfbd10
17 changed files with 139 additions and 56 deletions
|
@ -134,6 +134,7 @@ option(LWS_WITH_SEQUENCER "lws_seq_t support" ON)
|
|||
option(LWS_WITH_EXTERNAL_POLL "Support external POLL integration using callback messages (not recommended)" OFF)
|
||||
option(LWS_WITH_LWS_DSH "Support lws_dsh_t Disordered Shared Heap" OFF)
|
||||
option(LWS_CLIENT_HTTP_PROXYING "Support external http proxies for client connections" ON)
|
||||
option(LWS_WITH_FILE_OPS "Support file operations vfs" ON)
|
||||
#
|
||||
# to use miniz, enable both LWS_WITH_ZLIB and LWS_WITH_MINIZ
|
||||
#
|
||||
|
@ -985,10 +986,13 @@ set(SOURCES
|
|||
lib/core/libwebsockets.c
|
||||
lib/core/logs.c
|
||||
lib/misc/base64-decode.c
|
||||
lib/core/vfs.c
|
||||
lib/misc/lws-ring.c
|
||||
)
|
||||
|
||||
if (LWS_WITH_FILE_OPS)
|
||||
list(APPEND SOURCES lib/core/vfs.c)
|
||||
endif()
|
||||
|
||||
if (LWS_WITH_DEPRECATED_LWS_DLL)
|
||||
list(APPEND SOURCES
|
||||
lib/core/lws_dll.c)
|
||||
|
@ -1318,16 +1322,18 @@ else()
|
|||
if (LWS_WITH_ESP32)
|
||||
list(APPEND SOURCES
|
||||
lib/plat/esp32/esp32-fds.c
|
||||
lib/plat/esp32/esp32-file.c
|
||||
lib/plat/esp32/esp32-init.c
|
||||
lib/plat/esp32/esp32-misc.c
|
||||
lib/plat/esp32/esp32-pipe.c
|
||||
lib/plat/esp32/esp32-service.c
|
||||
lib/plat/esp32/esp32-sockets.c
|
||||
lib/misc/romfs.c)
|
||||
if(LWS_WITH_ESP32_HELPER)
|
||||
if (LWS_WITH_ESP32_HELPER)
|
||||
list(APPEND SOURCES lib/plat/esp32/esp32-helpers.c)
|
||||
endif()
|
||||
if (LWS_WITH_FILE_OPS)
|
||||
list(APPEND SOURCES lib/plat/esp32/esp32-file.c)
|
||||
endif()
|
||||
else()
|
||||
set(LWS_PLAT_UNIX 1)
|
||||
list(APPEND SOURCES
|
||||
|
|
|
@ -101,6 +101,7 @@
|
|||
#cmakedefine LWS_WITH_DIR
|
||||
#cmakedefine LWS_WITH_ESP32
|
||||
#cmakedefine LWS_WITH_EXTERNAL_POLL
|
||||
#cmakedefine LWS_WITH_FILE_OPS
|
||||
#cmakedefine LWS_WITH_FTS
|
||||
#cmakedefine LWS_WITH_GENCRYPTO
|
||||
#cmakedefine LWS_WITH_GENERIC_SESSIONS
|
||||
|
|
|
@ -238,8 +238,10 @@ LWS_VISIBLE int lws_write(struct lws *wsi, unsigned char *buf, size_t len,
|
|||
#ifdef LWS_WITH_ACCESS_LOG
|
||||
wsi->http.access_log.sent += len;
|
||||
#endif
|
||||
#if defined(LWS_WITH_SERVER_STATUS)
|
||||
if (wsi->vhost)
|
||||
wsi->vhost->conn_stats.tx += len;
|
||||
#endif
|
||||
|
||||
assert(wsi->role_ops);
|
||||
if (!wsi->role_ops->write_role_protocol)
|
||||
|
@ -279,8 +281,10 @@ lws_ssl_capable_read_no_ssl(struct lws *wsi, unsigned char *buf, int len)
|
|||
if (!n)
|
||||
return LWS_SSL_CAPABLE_ERROR;
|
||||
|
||||
#if defined(LWS_WITH_SERVER_STATUS)
|
||||
if (wsi->vhost)
|
||||
wsi->vhost->conn_stats.rx += n;
|
||||
#endif
|
||||
lws_stats_bump(pt, LWSSTATS_B_READ, n);
|
||||
|
||||
return n;
|
||||
|
|
|
@ -422,11 +422,13 @@ struct lws_context_per_thread {
|
|||
#endif
|
||||
};
|
||||
|
||||
#if defined(LWS_WITH_SERVER_STATUS)
|
||||
struct lws_conn_stats {
|
||||
unsigned long long rx, tx;
|
||||
unsigned long h1_conn, h1_trans, h2_trans, ws_upg, h2_alpn, h2_subs,
|
||||
h2_upg, rejected;
|
||||
};
|
||||
#endif
|
||||
|
||||
/*
|
||||
* virtual host -related context information
|
||||
|
@ -448,7 +450,7 @@ struct lws_conn_stats {
|
|||
|
||||
|
||||
struct lws_vhost {
|
||||
#if defined(LWS_WITH_CLIENT)
|
||||
#if defined(LWS_WITH_CLIENT) && defined(LWS_CLIENT_HTTP_PROXYING)
|
||||
char proxy_basic_auth_token[128];
|
||||
#endif
|
||||
#if LWS_MAX_SMP > 1
|
||||
|
@ -474,7 +476,10 @@ struct lws_vhost {
|
|||
#if defined(LWS_WITH_LIBEV)
|
||||
struct lws_io_watcher w_accept;
|
||||
#endif
|
||||
#if defined(LWS_WITH_SERVER_STATUS)
|
||||
struct lws_conn_stats conn_stats;
|
||||
#endif
|
||||
|
||||
struct lws_context *context;
|
||||
struct lws_vhost *vhost_next;
|
||||
|
||||
|
@ -488,9 +493,6 @@ struct lws_vhost {
|
|||
void (*finalize)(struct lws_vhost *vh, void *arg);
|
||||
void *finalize_arg;
|
||||
|
||||
#if !defined(LWS_WITH_ESP32) && !defined(OPTEE_TA) && !defined(WIN32)
|
||||
int bind_iface;
|
||||
#endif
|
||||
const struct lws_protocols *protocols;
|
||||
void **protocol_vh_privs;
|
||||
const struct lws_protocol_vhost_options *pvo;
|
||||
|
@ -511,6 +513,9 @@ struct lws_vhost {
|
|||
void *user;
|
||||
|
||||
int listen_port;
|
||||
#if !defined(LWS_WITH_ESP32) && !defined(OPTEE_TA) && !defined(WIN32)
|
||||
int bind_iface;
|
||||
#endif
|
||||
|
||||
#if defined(LWS_WITH_SOCKS5)
|
||||
unsigned int socks_proxy_port;
|
||||
|
@ -970,9 +975,10 @@ lws_destroy_event_pipe(struct lws *wsi);
|
|||
int
|
||||
socks_generate_msg(struct lws *wsi, enum socks_msg_type type, ssize_t *msg_len);
|
||||
|
||||
|
||||
#if defined(LWS_WITH_SERVER_STATUS)
|
||||
void
|
||||
lws_sum_stats(const struct lws_context *ctx, struct lws_conn_stats *cs);
|
||||
#endif
|
||||
|
||||
LWS_EXTERN int
|
||||
__lws_timed_callback_remove(struct lws_vhost *vh, struct lws_timed_vh_protocol *p);
|
||||
|
|
|
@ -1091,7 +1091,10 @@ __lws_vhost_destroy2(struct lws_vhost *vh)
|
|||
lws_ssl_SSL_CTX_destroy(vh);
|
||||
lws_free(vh->same_vh_protocol_owner);
|
||||
|
||||
if (context->plugin_list ||
|
||||
if (
|
||||
#if defined(LWS_WITH_PLUGINS)
|
||||
context->plugin_list ||
|
||||
#endif
|
||||
(context->options & LWS_SERVER_OPTION_EXPLICIT_VHOSTS) ||
|
||||
vh->allocated_vhost_protocols)
|
||||
lws_free((void *)vh->protocols);
|
||||
|
@ -1261,7 +1264,7 @@ lws_get_vhost_listen_port(struct lws_vhost *vhost)
|
|||
return vhost->listen_port;
|
||||
}
|
||||
|
||||
|
||||
#if defined(LWS_WITH_SERVER)
|
||||
LWS_VISIBLE LWS_EXTERN void
|
||||
lws_context_deprecate(struct lws_context *context, lws_reload_func cb)
|
||||
{
|
||||
|
@ -1302,6 +1305,7 @@ lws_context_deprecate(struct lws_context *context, lws_reload_func cb)
|
|||
context->deprecated = 1;
|
||||
context->deprecation_cb = cb;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(LWS_WITH_NETWORK)
|
||||
struct lws_vhost *
|
||||
|
|
|
@ -74,16 +74,20 @@ LWS_VISIBLE struct lws_context *
|
|||
lws_create_context(const struct lws_context_creation_info *info)
|
||||
{
|
||||
struct lws_context *context = NULL;
|
||||
#if defined(LWS_WITH_FILE_OPS)
|
||||
struct lws_plat_file_ops *prev;
|
||||
#endif
|
||||
#ifndef LWS_NO_DAEMONIZE
|
||||
pid_t pid_daemon = get_daemonize_pid();
|
||||
#endif
|
||||
#if defined(LWS_WITH_NETWORK)
|
||||
int n;
|
||||
int n, count_threads = 1;
|
||||
uint8_t *u;
|
||||
#endif
|
||||
#if defined(__ANDROID__)
|
||||
struct rlimit rt;
|
||||
#endif
|
||||
size_t s1 = 4096, size = sizeof(struct lws_context);
|
||||
|
||||
lwsl_info("Initial logging level %d\n", log_level);
|
||||
lwsl_info("Libwebsockets version: %s\n", library_version);
|
||||
|
@ -113,7 +117,20 @@ lws_create_context(const struct lws_context_creation_info *info)
|
|||
if (lws_plat_context_early_init())
|
||||
return NULL;
|
||||
|
||||
context = lws_zalloc(sizeof(struct lws_context), "context");
|
||||
#if defined(LWS_WITH_NETWORK)
|
||||
if (info->count_threads)
|
||||
count_threads = info->count_threads;
|
||||
|
||||
if (count_threads > LWS_MAX_SMP)
|
||||
count_threads = LWS_MAX_SMP;
|
||||
|
||||
if (info->pt_serv_buf_size)
|
||||
s1 = info->pt_serv_buf_size;
|
||||
|
||||
size += count_threads * (s1 + sizeof(struct lws));
|
||||
#endif
|
||||
|
||||
context = lws_zalloc(size, "context");
|
||||
if (!context) {
|
||||
lwsl_err("No memory for websocket context\n");
|
||||
return NULL;
|
||||
|
@ -124,12 +141,16 @@ lws_create_context(const struct lws_context_creation_info *info)
|
|||
context->username = info->username;
|
||||
context->groupname = info->groupname;
|
||||
context->system_ops = info->system_ops;
|
||||
context->pt_serv_buf_size = s1;
|
||||
#if defined(LWS_WITH_NETWORK)
|
||||
context->count_threads = count_threads;
|
||||
#endif
|
||||
|
||||
/* if he gave us names, set the uid / gid */
|
||||
if (lws_plat_drop_app_privileges(context, 0))
|
||||
goto bail;
|
||||
|
||||
lwsl_info("context created\n");
|
||||
lwsl_info("context created\n");
|
||||
#if defined(LWS_WITH_TLS) && defined(LWS_WITH_NETWORK)
|
||||
#if defined(LWS_WITH_MBEDTLS)
|
||||
context->tls_ops = &tls_ops_mbedtls;
|
||||
|
@ -138,10 +159,6 @@ lwsl_info("context created\n");
|
|||
#endif
|
||||
#endif
|
||||
|
||||
if (info->pt_serv_buf_size)
|
||||
context->pt_serv_buf_size = info->pt_serv_buf_size;
|
||||
else
|
||||
context->pt_serv_buf_size = 4096;
|
||||
|
||||
#if defined(LWS_ROLE_H2)
|
||||
role_ops_h2.init_context(context, info);
|
||||
|
@ -159,6 +176,7 @@ lwsl_info("context created\n");
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(LWS_WITH_FILE_OPS)
|
||||
/* default to just the platform fops implementation */
|
||||
|
||||
context->fops_platform.LWS_FOP_OPEN = _lws_plat_file_open;
|
||||
|
@ -189,8 +207,11 @@ lwsl_info("context created\n");
|
|||
/* if user provided fops, tack them on the end of the list */
|
||||
if (info->fops)
|
||||
prev->next = info->fops;
|
||||
#endif
|
||||
|
||||
#if defined(LWS_WITH_SERVER)
|
||||
context->reject_service_keywords = info->reject_service_keywords;
|
||||
#endif
|
||||
if (info->external_baggage_free_on_destroy)
|
||||
context->external_baggage_free_on_destroy =
|
||||
info->external_baggage_free_on_destroy;
|
||||
|
@ -211,35 +232,27 @@ lwsl_info("context created\n");
|
|||
}
|
||||
#endif
|
||||
#if defined(__ANDROID__)
|
||||
n = getrlimit(RLIMIT_NOFILE, &rt);
|
||||
if (n == -1) {
|
||||
lwsl_err("Get RLIMIT_NOFILE failed!\n");
|
||||
n = getrlimit(RLIMIT_NOFILE, &rt);
|
||||
if (n == -1) {
|
||||
lwsl_err("Get RLIMIT_NOFILE failed!\n");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
context->max_fds = rt.rlim_cur;
|
||||
return NULL;
|
||||
}
|
||||
context->max_fds = rt.rlim_cur;
|
||||
#else
|
||||
#if defined(WIN32) || defined(_WIN32) || defined(LWS_AMAZON_RTOS)
|
||||
context->max_fds = getdtablesize();
|
||||
context->max_fds = getdtablesize();
|
||||
#else
|
||||
context->max_fds = sysconf(_SC_OPEN_MAX);
|
||||
context->max_fds = sysconf(_SC_OPEN_MAX);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (context->max_fds < 0) {
|
||||
lwsl_err("%s: problem getting process max files\n",
|
||||
__func__);
|
||||
if (context->max_fds < 0) {
|
||||
lwsl_err("%s: problem getting process max files\n",
|
||||
__func__);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (info->count_threads)
|
||||
context->count_threads = info->count_threads;
|
||||
else
|
||||
context->count_threads = 1;
|
||||
|
||||
if (context->count_threads > LWS_MAX_SMP)
|
||||
context->count_threads = LWS_MAX_SMP;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* deal with any max_fds override, if it's reducing (setting it to
|
||||
|
@ -359,14 +372,10 @@ lwsl_info("context created\n");
|
|||
* Allocate the per-thread storage for scratchpad buffers,
|
||||
* and header data pool
|
||||
*/
|
||||
u = (uint8_t *)&context[1];
|
||||
for (n = 0; n < context->count_threads; n++) {
|
||||
context->pt[n].serv_buf = lws_malloc(
|
||||
context->pt_serv_buf_size + sizeof(struct lws),
|
||||
"pt_serv_buf");
|
||||
if (!context->pt[n].serv_buf) {
|
||||
lwsl_err("OOM\n");
|
||||
return NULL;
|
||||
}
|
||||
context->pt[n].serv_buf = u;
|
||||
u += context->pt_serv_buf_size;
|
||||
|
||||
context->pt[n].context = context;
|
||||
context->pt[n].tid = n;
|
||||
|
@ -378,8 +387,8 @@ lwsl_info("context created\n");
|
|||
* when the source of the callback is not actually from a wsi
|
||||
* context.
|
||||
*/
|
||||
context->pt[n].fake_wsi = (struct lws *)(context->pt[n].serv_buf +
|
||||
context->pt_serv_buf_size);
|
||||
context->pt[n].fake_wsi = (struct lws *)u;
|
||||
u += sizeof(struct lws);
|
||||
|
||||
memset(context->pt[n].fake_wsi, 0, sizeof(struct lws));
|
||||
|
||||
|
@ -442,11 +451,13 @@ lwsl_info("context created\n");
|
|||
}
|
||||
lwsl_info(" mem: pollfd map: %5u B\n", n);
|
||||
#endif
|
||||
#if defined(LWS_WITH_SERVER)
|
||||
if (info->server_string) {
|
||||
context->server_string = info->server_string;
|
||||
context->server_string_len = (short)
|
||||
strlen(context->server_string);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LWS_MAX_SMP > 1
|
||||
/* each thread serves his own chunk of fds */
|
||||
|
@ -492,8 +503,7 @@ lwsl_info("context created\n");
|
|||
if (!lws_check_opt(info->options, LWS_SERVER_OPTION_EXPLICIT_VHOSTS))
|
||||
if (!lws_create_vhost(context, info)) {
|
||||
lwsl_err("Failed to create default vhost\n");
|
||||
for (n = 0; n < context->count_threads; n++)
|
||||
lws_free_set_NULL(context->pt[n].serv_buf);
|
||||
|
||||
#if defined(LWS_WITH_PEER_LIMITS)
|
||||
lws_free_set_NULL(context->pl_hash_table);
|
||||
#endif
|
||||
|
@ -508,10 +518,13 @@ lwsl_info("context created\n");
|
|||
lwsl_info(" mem: per-conn: %5lu bytes + protocol rx buf\n",
|
||||
(unsigned long)sizeof(struct lws));
|
||||
#endif
|
||||
|
||||
#if defined(LWS_WITH_SERVER)
|
||||
strcpy(context->canonical_hostname, "unknown");
|
||||
#if defined(LWS_WITH_NETWORK)
|
||||
lws_server_get_canonical_hostname(context, info);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(LWS_WITH_STATS)
|
||||
context->pt[0].sul_stats.cb = lws_sul_stats_cb;
|
||||
|
@ -620,8 +633,6 @@ lws_context_destroy3(struct lws_context *context)
|
|||
if (context->event_loop_ops->destroy_pt)
|
||||
context->event_loop_ops->destroy_pt(context, n);
|
||||
|
||||
lws_free_set_NULL(context->pt[n].serv_buf);
|
||||
|
||||
#if defined(LWS_ROLE_H1) || defined(LWS_ROLE_H2)
|
||||
while (pt->http.ah_list)
|
||||
_lws_destroy_ah(pt, pt->http.ah_list);
|
||||
|
|
|
@ -150,11 +150,14 @@ lws_now_secs(void)
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(LWS_WITH_SERVER)
|
||||
LWS_VISIBLE extern const char *
|
||||
lws_canonical_hostname(struct lws_context *context)
|
||||
{
|
||||
return (const char *)context->canonical_hostname;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(LWS_WITH_SOCKS5)
|
||||
LWS_VISIBLE int
|
||||
|
|
|
@ -261,11 +261,15 @@ struct lws_deferred_free
|
|||
struct lws_context {
|
||||
time_t last_ws_ping_pong_check_s;
|
||||
lws_usec_t time_up; /* monotonic */
|
||||
#if defined(LWS_WITH_FILE_OPS)
|
||||
const struct lws_plat_file_ops *fops;
|
||||
struct lws_plat_file_ops fops_platform;
|
||||
#endif
|
||||
struct lws_context **pcontext_finalize;
|
||||
|
||||
#if defined(LWS_WITH_TLS)
|
||||
const struct lws_tls_ops *tls_ops;
|
||||
#endif
|
||||
|
||||
const char *username, *groupname;
|
||||
|
||||
|
@ -277,11 +281,15 @@ struct lws_context {
|
|||
#endif
|
||||
#if defined(LWS_WITH_NETWORK)
|
||||
struct lws_context_per_thread pt[LWS_MAX_SMP];
|
||||
#if defined(LWS_WITH_SERVER_STATUS)
|
||||
struct lws_conn_stats conn_stats;
|
||||
#endif
|
||||
struct lws_vhost *vhost_list;
|
||||
struct lws_vhost *no_listener_vhost_list;
|
||||
struct lws_vhost *vhost_pending_destruction_list;
|
||||
#if defined(LWS_WITH_PLUGINS)
|
||||
struct lws_plugin *plugin_list;
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
/* different implementation between unix and windows */
|
||||
struct lws_fd_hashtable fd_hashtable[FD_HASHTABLE_MODULUS];
|
||||
|
@ -315,8 +323,10 @@ struct lws_context {
|
|||
void *external_baggage_free_on_destroy;
|
||||
const struct lws_token_limits *token_limits;
|
||||
void *user_space;
|
||||
#if defined(LWS_WITH_SERVER)
|
||||
const struct lws_protocol_vhost_options *reject_service_keywords;
|
||||
lws_reload_func deprecation_cb;
|
||||
#endif
|
||||
void (*eventlib_signal_cb)(void *event_lib_handle, int signum);
|
||||
|
||||
#if defined(LWS_HAVE_SYS_CAPABILITY_H) && defined(LWS_HAVE_LIBCAP)
|
||||
|
@ -341,8 +351,10 @@ struct lws_context {
|
|||
struct lws_context_tls tls;
|
||||
#endif
|
||||
|
||||
#if defined(LWS_WITH_SERVER)
|
||||
char canonical_hostname[128];
|
||||
const char *server_string;
|
||||
#endif
|
||||
|
||||
#ifdef LWS_LATENCY
|
||||
unsigned long worst_latency;
|
||||
|
|
|
@ -705,6 +705,7 @@ esp_err_t lws_esp32_event_passthru(void *ctx, system_event_t *event)
|
|||
return ESP_OK;
|
||||
}
|
||||
|
||||
#if defined(LWS_WITH_FILE_OPS)
|
||||
static lws_fop_fd_t IRAM_ATTR
|
||||
esp32_lws_fops_open(const struct lws_plat_file_ops *fops, const char *filename,
|
||||
const char *vfs_path, lws_fop_flags_t *flags)
|
||||
|
@ -796,6 +797,7 @@ static const struct lws_plat_file_ops fops = {
|
|||
.LWS_FOP_READ = esp32_lws_fops_read,
|
||||
.LWS_FOP_SEEK_CUR = esp32_lws_fops_seek_cur,
|
||||
};
|
||||
#endif
|
||||
|
||||
int
|
||||
lws_esp32_wlan_nvs_get(int retry)
|
||||
|
@ -1296,8 +1298,9 @@ lws_esp32_init(struct lws_context_creation_info *info, struct lws_vhost **pvh)
|
|||
puts(buf);
|
||||
|
||||
/* set the lws vfs to use our romfs */
|
||||
|
||||
#if defined(LWS_WITH_FILE_OPS)
|
||||
lws_set_fops(context, &fops);
|
||||
#endif
|
||||
|
||||
info->options |= LWS_SERVER_OPTION_CREATE_VHOST_SSL_CTX |
|
||||
LWS_SERVER_OPTION_IGNORE_MISSING_CERT;
|
||||
|
|
|
@ -88,7 +88,7 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi)
|
|||
timeout_us = ((lws_usec_t)timeout_ms) * LWS_US_PER_MS;
|
||||
|
||||
if (!pt->service_tid_detected) {
|
||||
struct lws *_lws = lws_zalloc(sizeof(*_lws), "tid probe");
|
||||
struct lws *_lws = pt->fake_wsi;
|
||||
|
||||
if (!_lws)
|
||||
return 1;
|
||||
|
@ -97,7 +97,6 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi)
|
|||
pt->service_tid = context->vhost_list->protocols[0].callback(
|
||||
_lws, LWS_CALLBACK_GET_THREAD_ID, NULL, NULL, 0);
|
||||
pt->service_tid_detected = 1;
|
||||
lws_free(_lws);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -208,7 +208,9 @@ lws_wsi_server_new(struct lws_vhost *vh, struct lws *parent_wsi,
|
|||
if (lws_ensure_user_space(wsi))
|
||||
goto bail1;
|
||||
|
||||
#if defined(LWS_WITH_SERVER_STATUS)
|
||||
wsi->vhost->conn_stats.h2_subs++;
|
||||
#endif
|
||||
|
||||
lwsl_info("%s: %p new ch %p, sid %d, usersp=%p, tx cr %d, "
|
||||
"peer_credit %d (nwsi tx_cr %d)\n",
|
||||
|
@ -273,7 +275,9 @@ lws_wsi_h2_adopt(struct lws *parent_wsi, struct lws *wsi)
|
|||
|
||||
lws_callback_on_writable(wsi);
|
||||
|
||||
#if defined(LWS_WITH_SERVER_STATUS)
|
||||
wsi->vhost->conn_stats.h2_subs++;
|
||||
#endif
|
||||
|
||||
return wsi;
|
||||
|
||||
|
@ -711,7 +715,9 @@ int lws_h2_do_pps_send(struct lws *wsi)
|
|||
h2n->swsi->h2.END_STREAM = 1;
|
||||
lwsl_info("servicing initial http request\n");
|
||||
|
||||
#if defined(LWS_WITH_SERVER_STATUS)
|
||||
wsi->vhost->conn_stats.h2_trans++;
|
||||
#endif
|
||||
|
||||
if (lws_http_action(h2n->swsi))
|
||||
goto bail;
|
||||
|
@ -1500,7 +1506,9 @@ lws_h2_parse_end_of_frame(struct lws *wsi)
|
|||
lws_http_compression_validate(h2n->swsi);
|
||||
#endif
|
||||
|
||||
#if defined(LWS_WITH_SERVER_STATUS)
|
||||
wsi->vhost->conn_stats.h2_trans++;
|
||||
#endif
|
||||
p = lws_hdr_simple_ptr(h2n->swsi, WSI_TOKEN_HTTP_COLON_METHOD);
|
||||
/*
|
||||
* duplicate :path into the individual method uri header
|
||||
|
|
|
@ -503,7 +503,9 @@ rops_check_upgrades_h2(struct lws *wsi)
|
|||
|
||||
nwsi = lws_get_network_wsi(wsi);
|
||||
|
||||
#if defined(LWS_WITH_SERVER_STATUS)
|
||||
wsi->vhost->conn_stats.ws_upg++;
|
||||
#endif
|
||||
lwsl_info("Upgrade h2 to ws\n");
|
||||
wsi->h2_stream_carries_ws = 1;
|
||||
nwsi->immortal_substream_count++;
|
||||
|
@ -1184,7 +1186,9 @@ rops_alpn_negotiated_h2(struct lws *wsi, const char *alpn)
|
|||
#endif
|
||||
|
||||
wsi->upgraded_to_http2 = 1;
|
||||
#if defined(LWS_WITH_SERVER_STATUS)
|
||||
wsi->vhost->conn_stats.h2_alpn++;
|
||||
#endif
|
||||
|
||||
/* adopt the header info */
|
||||
|
||||
|
|
|
@ -308,7 +308,9 @@ lejp_globals_cb(struct lejp_ctx *ctx, char reason)
|
|||
a->info->options |= LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT;
|
||||
return 0;
|
||||
case LEJPGP_SERVER_STRING:
|
||||
#if defined(LWS_WITH_SERVER)
|
||||
a->info->server_string = a->p;
|
||||
#endif
|
||||
break;
|
||||
case LEJPGP_PLUGIN_DIR:
|
||||
if (a->count_plugin_dirs == MAX_PLUGIN_DIRS - 1) {
|
||||
|
@ -358,7 +360,9 @@ lejp_vhosts_cb(struct lejp_ctx *ctx, char reason)
|
|||
|
||||
if (reason == LEJPCB_OBJECT_START && ctx->path_match == LEJPVP + 1) {
|
||||
uint32_t i[4];
|
||||
#if defined(LWS_WITH_SERVER)
|
||||
const char *ss;
|
||||
#endif
|
||||
|
||||
/* set the defaults for this vhost */
|
||||
a->reject_ws_with_no_protocol = 0;
|
||||
|
@ -376,7 +380,9 @@ lejp_vhosts_cb(struct lejp_ctx *ctx, char reason)
|
|||
LWS_SERVER_OPTION_LIBEVENT |
|
||||
LWS_SERVER_OPTION_LIBEV
|
||||
);
|
||||
#if defined(LWS_WITH_SERVER)
|
||||
ss = a->info->server_string;
|
||||
#endif
|
||||
i[2] = a->info->ws_ping_pong_interval;
|
||||
i[3] = a->info->timeout_secs;
|
||||
|
||||
|
@ -384,7 +390,9 @@ lejp_vhosts_cb(struct lejp_ctx *ctx, char reason)
|
|||
|
||||
a->info->count_threads = i[0];
|
||||
a->info->options = i[1];
|
||||
#if defined(LWS_WITH_SERVER)
|
||||
a->info->server_string = ss;
|
||||
#endif
|
||||
a->info->ws_ping_pong_interval = i[2];
|
||||
a->info->timeout_secs = i[3];
|
||||
|
||||
|
|
|
@ -1912,9 +1912,13 @@ raw_transition:
|
|||
lwsl_info("no host\n");
|
||||
|
||||
if (!lwsi_role_h2(wsi) || !lwsi_role_server(wsi)) {
|
||||
#if defined(LWS_WITH_SERVER_STATUS)
|
||||
wsi->vhost->conn_stats.h1_trans++;
|
||||
#endif
|
||||
if (!wsi->conn_stat_done) {
|
||||
#if defined(LWS_WITH_SERVER_STATUS)
|
||||
wsi->vhost->conn_stats.h1_conn++;
|
||||
#endif
|
||||
wsi->conn_stat_done = 1;
|
||||
}
|
||||
}
|
||||
|
@ -1953,7 +1957,9 @@ raw_transition:
|
|||
|
||||
/* wsi close will do the log */
|
||||
#endif
|
||||
#if defined(LWS_WITH_SERVER_STATUS)
|
||||
wsi->vhost->conn_stats.rejected++;
|
||||
#endif
|
||||
/*
|
||||
* We don't want anything from
|
||||
* this rejected guy. Follow
|
||||
|
@ -2019,14 +2025,18 @@ raw_transition:
|
|||
|
||||
if (!strcasecmp(up, "websocket")) {
|
||||
#if defined(LWS_ROLE_WS)
|
||||
#if defined(LWS_WITH_SERVER_STATUS)
|
||||
wsi->vhost->conn_stats.ws_upg++;
|
||||
#endif
|
||||
lwsl_info("Upgrade to ws\n");
|
||||
goto upgrade_ws;
|
||||
#endif
|
||||
}
|
||||
#if defined(LWS_WITH_HTTP2)
|
||||
if (!strcasecmp(up, "h2c")) {
|
||||
#if defined(LWS_WITH_SERVER_STATUS)
|
||||
wsi->vhost->conn_stats.h2_upg++;
|
||||
#endif
|
||||
lwsl_info("Upgrade to h2c\n");
|
||||
goto upgrade_h2c;
|
||||
}
|
||||
|
@ -2881,7 +2891,7 @@ lws_server_get_canonical_hostname(struct lws_context *context,
|
|||
}
|
||||
#endif
|
||||
|
||||
LWS_VISIBLE LWS_EXTERN int
|
||||
int
|
||||
lws_chunked_html_process(struct lws_process_html_args *args,
|
||||
struct lws_process_html_state *s)
|
||||
{
|
||||
|
|
|
@ -109,8 +109,10 @@ lws_ssl_capable_read(struct lws *wsi, unsigned char *buf, int len)
|
|||
|
||||
lws_stats_bump(pt, LWSSTATS_B_READ, n);
|
||||
|
||||
#if defined(LWS_WITH_SERVER_STATUS)
|
||||
if (wsi->vhost)
|
||||
wsi->vhost->conn_stats.rx += n;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* if it was our buffer that limited what we read,
|
||||
|
|
|
@ -264,8 +264,10 @@ lws_ssl_capable_read(struct lws *wsi, unsigned char *buf, int len)
|
|||
|
||||
lws_stats_bump(pt, LWSSTATS_B_READ, n);
|
||||
|
||||
#if defined(LWS_WITH_SERVER_STATUS)
|
||||
if (wsi->vhost)
|
||||
wsi->vhost->conn_stats.rx += n;
|
||||
#endif
|
||||
|
||||
// lwsl_hexdump_err(buf, n);
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
#include <mbedtls/aes.h>
|
||||
#include <mbedtls/gcm.h>
|
||||
#include <mbedtls/x509_crt.h>
|
||||
#include "openssl/ssl.h" /* wrapper !!!! */
|
||||
#include "ssl.h" /* wrapper !!!! */
|
||||
#else /* not esp32 */
|
||||
#if defined(LWS_WITH_MBEDTLS)
|
||||
#include <mbedtls/ssl.h>
|
||||
|
|
Loading…
Add table
Reference in a new issue