Project homepage Mailing List  Warmcat.com  API Docs  Github Mirror 
{"schema":"libjg2-1", "vpath":"/git/", "avatar":"/git/avatar/", "alang":"", "gen_ut":1711650377, "reponame":"libwebsockets", "desc":"libwebsockets lightweight C networking library", "owner": { "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },"url":"https://libwebsockets.org/repo/libwebsockets", "f":3, "items": [ {"schema":"libjg2-1", "cid":"d4dedec05687308c1095f6cd704af9b2", "oid":{ "oid": "e4be3317ee421f951fb16a85c7edacc9b8a0e6aa", "alias": [ "refs/heads/main"]},"blobname": "lib/roles/http/server/lejp-conf.c", "blob": "/*\n * libwebsockets - small server side websockets and web server implementation\n *\n * Copyright (C) 2010 - 2019 Andy Green \u003candy@warmcat.com\u003e\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \u0022Software\u0022), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \u0022AS IS\u0022, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\n#include \u0022private-lib-core.h\u0022\n\n#ifndef _WIN32\n/* this is needed for Travis CI */\n#include \u003cdirent.h\u003e\n#endif\n\n#define ESC_INSTALL_DATADIR \u0022_lws_ddir_\u0022\n\nstatic const char * const paths_global[] \u003d {\n\t\u0022global.uid\u0022,\n\t\u0022global.gid\u0022,\n\t\u0022global.username\u0022,\n\t\u0022global.groupname\u0022,\n\t\u0022global.count-threads\u0022,\n\t\u0022global.init-ssl\u0022,\n\t\u0022global.server-string\u0022,\n\t\u0022global.plugin-dir\u0022,\n\t\u0022global.ws-pingpong-secs\u0022, /* deprecated */\n\t\u0022global.timeout-secs\u0022,\n\t\u0022global.reject-service-keywords[].*\u0022,\n\t\u0022global.reject-service-keywords[]\u0022,\n\t\u0022global.default-alpn\u0022,\n\t\u0022global.ip-limit-ah\u0022,\n\t\u0022global.ip-limit-wsi\u0022,\n\t\u0022global.rlimit-nofile\u0022,\n};\n\nenum lejp_global_paths {\n\tLEJPGP_UID,\n\tLEJPGP_GID,\n\tLEJPGP_USERNAME,\n\tLEJPGP_GROUPNAME,\n\tLEJPGP_COUNT_THREADS,\n\tLWJPGP_INIT_SSL,\n\tLEJPGP_SERVER_STRING,\n\tLEJPGP_PLUGIN_DIR,\n\tLWJPGP_PINGPONG_SECS,\n\tLWJPGP_TIMEOUT_SECS,\n\tLWJPGP_REJECT_SERVICE_KEYWORDS_NAME,\n\tLWJPGP_REJECT_SERVICE_KEYWORDS,\n\tLWJPGP_DEFAULT_ALPN,\n\tLWJPGP_IP_LIMIT_AH,\n\tLWJPGP_IP_LIMIT_WSI,\n\tLWJPGP_FD_LIMIT_PT,\n};\n\nstatic const char * const paths_vhosts[] \u003d {\n\t\u0022vhosts[]\u0022,\n\t\u0022vhosts[].name\u0022,\n\t\u0022vhosts[].port\u0022,\n\t\u0022vhosts[].interface\u0022,\n\t\u0022vhosts[].unix-socket\u0022,\n\t\u0022vhosts[].unix-socket-perms\u0022,\n\t\u0022vhosts[].sts\u0022,\n\t\u0022vhosts[].host-ssl-key\u0022,\n\t\u0022vhosts[].host-ssl-cert\u0022,\n\t\u0022vhosts[].host-ssl-ca\u0022,\n\t\u0022vhosts[].access-log\u0022,\n\t\u0022vhosts[].mounts[].mountpoint\u0022,\n\t\u0022vhosts[].mounts[].origin\u0022,\n\t\u0022vhosts[].mounts[].protocol\u0022,\n\t\u0022vhosts[].mounts[].default\u0022,\n\t\u0022vhosts[].mounts[].auth-mask\u0022,\n\t\u0022vhosts[].mounts[].cgi-timeout\u0022,\n\t\u0022vhosts[].mounts[].cgi-env[].*\u0022,\n\t\u0022vhosts[].mounts[].cgi-env[]\u0022,\n\t\u0022vhosts[].mounts[].cache-max-age\u0022,\n\t\u0022vhosts[].mounts[].cache-reuse\u0022,\n\t\u0022vhosts[].mounts[].cache-revalidate\u0022,\n\t\u0022vhosts[].mounts[].cache-no\u0022,\n\t\u0022vhosts[].mounts[].basic-auth\u0022,\n\t\u0022vhosts[].mounts[].cache-intermediaries\u0022,\n\t\u0022vhosts[].mounts[].extra-mimetypes.*\u0022,\n\t\u0022vhosts[].mounts[].extra-mimetypes\u0022,\n\t\u0022vhosts[].mounts[].interpret.*\u0022,\n\t\u0022vhosts[].mounts[].interpret\u0022,\n\t\u0022vhosts[].mounts[]\u0022,\n\t\u0022vhosts[].ws-protocols[].*.*\u0022,\n\t\u0022vhosts[].ws-protocols[].*\u0022,\n\t\u0022vhosts[].ws-protocols[]\u0022,\n\t\u0022vhosts[].keepalive_timeout\u0022,\n\t\u0022vhosts[].enable-client-ssl\u0022,\n\t\u0022vhosts[].ciphers\u0022,\n\t\u0022vhosts[].ecdh-curve\u0022,\n\t\u0022vhosts[].noipv6\u0022,\n\t\u0022vhosts[].ipv6only\u0022,\n\t\u0022vhosts[].ssl-option-set\u0022,\n\t\u0022vhosts[].ssl-option-clear\u0022,\n\t\u0022vhosts[].mounts[].pmo[].*\u0022,\n\t\u0022vhosts[].mounts[].pmo[]\u0022,\n\t\u0022vhosts[].headers[].*\u0022,\n\t\u0022vhosts[].headers[]\u0022,\n\t\u0022vhosts[].client-ssl-key\u0022,\n\t\u0022vhosts[].client-ssl-cert\u0022,\n\t\u0022vhosts[].client-ssl-ca\u0022,\n\t\u0022vhosts[].client-ssl-ciphers\u0022,\n\t\u0022vhosts[].onlyraw\u0022,\n\t\u0022vhosts[].client-cert-required\u0022,\n\t\u0022vhosts[].ignore-missing-cert\u0022,\n\t\u0022vhosts[].error-document-404\u0022,\n\t\u0022vhosts[].alpn\u0022,\n\t\u0022vhosts[].fo-listen-queue\u0022,\n\t\u0022vhosts[].ssl-client-option-set\u0022,\n\t\u0022vhosts[].ssl-client-option-clear\u0022,\n\t\u0022vhosts[].tls13-ciphers\u0022,\n\t\u0022vhosts[].client-tls13-ciphers\u0022,\n\t\u0022vhosts[].strict-host-check\u0022,\n\n\t\u0022vhosts[].listen-accept-role\u0022,\n\t\u0022vhosts[].listen-accept-protocol\u0022,\n\t\u0022vhosts[].apply-listen-accept\u0022, /* deprecates \u0022onlyraw\u0022 */\n\t\u0022vhosts[].fallback-listen-accept\u0022,\n\t\u0022vhosts[].allow-non-tls\u0022,\n\t\u0022vhosts[].redirect-http\u0022,\n\t\u0022vhosts[].allow-http-on-https\u0022,\n\n\t\u0022vhosts[].disable-no-protocol-ws-upgrades\u0022,\n\t\u0022vhosts[].h2-half-closed-long-poll\u0022,\n};\n\nenum lejp_vhost_paths {\n\tLEJPVP,\n\tLEJPVP_NAME,\n\tLEJPVP_PORT,\n\tLEJPVP_INTERFACE,\n\tLEJPVP_UNIXSKT,\n\tLEJPVP_UNIXSKT_PERMS,\n\tLEJPVP_STS,\n\tLEJPVP_HOST_SSL_KEY,\n\tLEJPVP_HOST_SSL_CERT,\n\tLEJPVP_HOST_SSL_CA,\n\tLEJPVP_ACCESS_LOG,\n\tLEJPVP_MOUNTPOINT,\n\tLEJPVP_ORIGIN,\n\tLEJPVP_MOUNT_PROTOCOL,\n\tLEJPVP_DEFAULT,\n\tLEJPVP_DEFAULT_AUTH_MASK,\n\tLEJPVP_CGI_TIMEOUT,\n\tLEJPVP_CGI_ENV,\n\tLEJPVP_CGI_ENV_base,\n\tLEJPVP_MOUNT_CACHE_MAX_AGE,\n\tLEJPVP_MOUNT_CACHE_REUSE,\n\tLEJPVP_MOUNT_CACHE_REVALIDATE,\n\tLEJPVP_MOUNT_CACHE_NO,\n\tLEJPVP_MOUNT_BASIC_AUTH,\n\tLEJPVP_MOUNT_CACHE_INTERMEDIARIES,\n\tLEJPVP_MOUNT_EXTRA_MIMETYPES,\n\tLEJPVP_MOUNT_EXTRA_MIMETYPES_base,\n\tLEJPVP_MOUNT_INTERPRET,\n\tLEJPVP_MOUNT_INTERPRET_base,\n\n\tLEJPVP_MOUNTS,\n\n\tLEJPVP_PROTOCOL_NAME_OPT,\n\tLEJPVP_PROTOCOL_NAME,\n\tLEJPVP_PROTOCOL,\n\tLEJPVP_KEEPALIVE_TIMEOUT,\n\tLEJPVP_ENABLE_CLIENT_SSL,\n\tLEJPVP_CIPHERS,\n\tLEJPVP_ECDH_CURVE,\n\tLEJPVP_NOIPV6,\n\tLEJPVP_IPV6ONLY,\n\tLEJPVP_SSL_OPTION_SET,\n\tLEJPVP_SSL_OPTION_CLEAR,\n\tLEJPVP_PMO,\n\tLEJPVP_PM_baseO,\n\tLEJPVP_HEADERS_NAME,\n\tLEJPVP_HEADERS,\n\tLEJPVP_CLIENT_SSL_KEY,\n\tLEJPVP_CLIENT_SSL_CERT,\n\tLEJPVP_CLIENT_SSL_CA,\n\tLEJPVP_CLIENT_CIPHERS,\n\tLEJPVP_FLAG_ONLYRAW,\n\tLEJPVP_FLAG_CLIENT_CERT_REQUIRED,\n\tLEJPVP_IGNORE_MISSING_CERT,\n\tLEJPVP_ERROR_DOCUMENT_404,\n\tLEJPVP_ALPN,\n\tLWJPVP_FO_LISTEN_QUEUE,\n\tLEJPVP_SSL_CLIENT_OPTION_SET,\n\tLEJPVP_SSL_CLIENT_OPTION_CLEAR,\n\tLEJPVP_TLS13_CIPHERS,\n\tLEJPVP_CLIENT_TLS13_CIPHERS,\n\tLEJPVP_FLAG_STRICT_HOST_CHECK,\n\n\tLEJPVP_LISTEN_ACCEPT_ROLE,\n\tLEJPVP_LISTEN_ACCEPT_PROTOCOL,\n\tLEJPVP_FLAG_APPLY_LISTEN_ACCEPT,\n\tLEJPVP_FLAG_FALLBACK_LISTEN_ACCEPT,\n\tLEJPVP_FLAG_ALLOW_NON_TLS,\n\tLEJPVP_FLAG_REDIRECT_HTTP,\n\tLEJPVP_FLAG_ALLOW_HTTP_ON_HTTPS,\n\n\tLEJPVP_FLAG_DISABLE_NO_PROTOCOL_WS_UPGRADES,\n\tLEJPVP_FLAG_H2_HALF_CLOSED_LONG_POLL,\n};\n\n#define MAX_PLUGIN_DIRS 10\n\nstruct jpargs {\n\tstruct lws_context_creation_info *info;\n\tstruct lws_context *context;\n\tconst struct lws_protocols *protocols;\n\tconst struct lws_protocols **pprotocols;\n\tconst struct lws_extension *extensions;\n\tchar *p, *end, valid;\n\tstruct lws_http_mount *head, *last;\n\n\tstruct lws_protocol_vhost_options *pvo;\n\tstruct lws_protocol_vhost_options *pvo_em;\n\tstruct lws_protocol_vhost_options *pvo_int;\n\tstruct lws_http_mount m;\n\tconst char **plugin_dirs;\n\tint count_plugin_dirs;\n\n\tunsigned int reject_ws_with_no_protocol:1;\n\tunsigned int enable_client_ssl:1;\n\tunsigned int fresh_mount:1;\n\tunsigned int any_vhosts:1;\n\tunsigned int chunk:1;\n};\n\nstatic void *\nlwsws_align(struct jpargs *a)\n{\n\tif ((lws_intptr_t)(a-\u003ep) \u0026 15)\n\t\ta-\u003ep +\u003d 16 - ((lws_intptr_t)(a-\u003ep) \u0026 15);\n\n\ta-\u003echunk \u003d 0;\n\n\treturn a-\u003ep;\n}\n\nstatic int\narg_to_bool(const char *s)\n{\n\tstatic const char * const on[] \u003d { \u0022on\u0022, \u0022yes\u0022, \u0022true\u0022 };\n\tint n \u003d atoi(s);\n\n\tif (n)\n\t\treturn 1;\n\n\tfor (n \u003d 0; n \u003c (int)LWS_ARRAY_SIZE(on); n++)\n\t\tif (!strcasecmp(s, on[n]))\n\t\t\treturn 1;\n\n\treturn 0;\n}\n\nstatic void\nset_reset_flag(uint64_t *p, const char *state, uint64_t flag)\n{\n\tif (arg_to_bool(state))\n\t\t*p |\u003d flag;\n\telse\n\t\t*p \u0026\u003d ~(flag);\n}\n\nstatic signed char\nlejp_globals_cb(struct lejp_ctx *ctx, char reason)\n{\n\tstruct jpargs *a \u003d (struct jpargs *)ctx-\u003euser;\n\tstruct lws_protocol_vhost_options *rej;\n\tint n;\n\n\t/* we only match on the prepared path strings */\n\tif (!(reason \u0026 LEJP_FLAG_CB_IS_VALUE) || !ctx-\u003epath_match)\n\t\treturn 0;\n\n\t/* this catches, eg, vhosts[].headers[].xxx */\n\tif (reason \u003d\u003d LEJPCB_VAL_STR_END \u0026\u0026\n\t ctx-\u003epath_match \u003d\u003d LWJPGP_REJECT_SERVICE_KEYWORDS_NAME + 1) {\n\t\trej \u003d lwsws_align(a);\n\t\ta-\u003ep +\u003d sizeof(*rej);\n\n\t\tn \u003d lejp_get_wildcard(ctx, 0, a-\u003ep, lws_ptr_diff(a-\u003eend, a-\u003ep));\n\t\trej-\u003enext \u003d a-\u003einfo-\u003ereject_service_keywords;\n\t\ta-\u003einfo-\u003ereject_service_keywords \u003d rej;\n\t\trej-\u003ename \u003d a-\u003ep;\n\t\t lwsl_notice(\u0022 adding rej %s\u003d%s\u005cn\u0022, a-\u003ep, ctx-\u003ebuf);\n\t\ta-\u003ep +\u003d n - 1;\n\t\t*(a-\u003ep++) \u003d '\u005c0';\n\t\trej-\u003evalue \u003d a-\u003ep;\n\t\trej-\u003eoptions \u003d NULL;\n\t\tgoto dostring;\n\t}\n\n\tswitch (ctx-\u003epath_match - 1) {\n\tcase LEJPGP_UID:\n\t\ta-\u003einfo-\u003euid \u003d (unsigned int)atoi(ctx-\u003ebuf);\n\t\treturn 0;\n\tcase LEJPGP_GID:\n\t\ta-\u003einfo-\u003egid \u003d (unsigned int)atoi(ctx-\u003ebuf);\n\t\treturn 0;\n\tcase LEJPGP_USERNAME:\n\t\ta-\u003einfo-\u003eusername \u003d a-\u003ep;\n\t\tbreak;\n\tcase LEJPGP_GROUPNAME:\n\t\ta-\u003einfo-\u003egroupname \u003d a-\u003ep;\n\t\tbreak;\n\tcase LEJPGP_COUNT_THREADS:\n\t\ta-\u003einfo-\u003ecount_threads \u003d (unsigned int)atoi(ctx-\u003ebuf);\n\t\treturn 0;\n\tcase LWJPGP_INIT_SSL:\n\t\tif (arg_to_bool(ctx-\u003ebuf))\n\t\t\ta-\u003einfo-\u003eoptions |\u003d LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT;\n\t\treturn 0;\n\tcase LEJPGP_SERVER_STRING:\n#if defined(LWS_WITH_SERVER)\n\t\ta-\u003einfo-\u003eserver_string \u003d a-\u003ep;\n#endif\n\t\tbreak;\n\tcase LEJPGP_PLUGIN_DIR:\n\t\tif (a-\u003ecount_plugin_dirs \u003d\u003d MAX_PLUGIN_DIRS - 1) {\n\t\t\tlwsl_err(\u0022Too many plugin dirs\u005cn\u0022);\n\t\t\treturn -1;\n\t\t}\n\t\ta-\u003eplugin_dirs[a-\u003ecount_plugin_dirs++] \u003d a-\u003ep;\n\t\tbreak;\n\n\tcase LWJPGP_PINGPONG_SECS: /* deprecated */\n\t\treturn 0;\n\n\tcase LWJPGP_TIMEOUT_SECS:\n\t\ta-\u003einfo-\u003etimeout_secs \u003d (unsigned int)atoi(ctx-\u003ebuf);\n\t\treturn 0;\n\n#if defined(LWS_WITH_TLS)\n\tcase LWJPGP_DEFAULT_ALPN:\n\t\ta-\u003einfo-\u003ealpn \u003d a-\u003ep;\n\t\tbreak;\n#endif\n\n#if defined(LWS_WITH_PEER_LIMITS)\n\tcase LWJPGP_IP_LIMIT_AH:\n\t\ta-\u003einfo-\u003eip_limit_ah \u003d (uint16_t)atoi(ctx-\u003ebuf);\n\t\treturn 0;\n\n\tcase LWJPGP_IP_LIMIT_WSI:\n\t\ta-\u003einfo-\u003eip_limit_wsi \u003d (uint16_t)atoi(ctx-\u003ebuf);\n\t\treturn 0;\n#endif\n\n\tcase LWJPGP_FD_LIMIT_PT:\n\t\ta-\u003einfo-\u003erlimit_nofile \u003d atoi(ctx-\u003ebuf);\n\t\treturn 0;\n\n\tdefault:\n\t\treturn 0;\n\t}\n\ndostring:\n\ta-\u003ep +\u003d lws_snprintf(a-\u003ep, lws_ptr_diff_size_t(a-\u003eend, a-\u003ep), \u0022%s\u0022, ctx-\u003ebuf);\n\t*(a-\u003ep)++ \u003d '\u005c0';\n\n\treturn 0;\n}\n\nstatic signed char\nlejp_vhosts_cb(struct lejp_ctx *ctx, char reason)\n{\n\tstruct jpargs *a \u003d (struct jpargs *)ctx-\u003euser;\n\tstruct lws_protocol_vhost_options *pvo, *mp_cgienv, *headers;\n\tstruct lws_http_mount *m;\n\tchar *p, *p1;\n\tint n;\n\n#if 0\n\tlwsl_notice(\u0022 %d: %s (%d)\u005cn\u0022, reason, ctx-\u003epath, ctx-\u003epath_match);\n\tfor (n \u003d 0; n \u003c ctx-\u003ewildcount; n++)\n\t\tlwsl_notice(\u0022 %d\u005cn\u0022, ctx-\u003ewild[n]);\n#endif\n\n\tif (reason \u003d\u003d LEJPCB_OBJECT_START \u0026\u0026 ctx-\u003epath_match \u003d\u003d LEJPVP + 1) {\n\t\tuint32_t i[4];\n#if defined(LWS_WITH_SERVER)\n\t\tconst char *ss;\n#endif\n\n\t\t/* set the defaults for this vhost */\n\t\ta-\u003ereject_ws_with_no_protocol \u003d 0;\n\t\ta-\u003evalid \u003d 1;\n\t\ta-\u003ehead \u003d NULL;\n\t\ta-\u003elast \u003d NULL;\n\n\t\ti[0] \u003d a-\u003einfo-\u003ecount_threads;\n\t\ti[1] \u003d a-\u003einfo-\u003eoptions \u0026 (\n\t\t\tLWS_SERVER_OPTION_SKIP_SERVER_CANONICAL_NAME |\n\t\t\tLWS_SERVER_OPTION_LIBUV |\n\t\t\tLWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT |\n\t\t\tLWS_SERVER_OPTION_EXPLICIT_VHOSTS |\n\t\t\tLWS_SERVER_OPTION_UV_NO_SIGSEGV_SIGFPE_SPIN |\n\t\t\tLWS_SERVER_OPTION_LIBEVENT |\n\t\t\tLWS_SERVER_OPTION_LIBEV\n\t\t\t\t);\n#if defined(LWS_WITH_SERVER)\n\t\tss \u003d a-\u003einfo-\u003eserver_string;\n#endif\n\t\ti[3] \u003d a-\u003einfo-\u003etimeout_secs;\n\n\t\tmemset(a-\u003einfo, 0, sizeof(*a-\u003einfo));\n\n\t\ta-\u003einfo-\u003ecount_threads \u003d i[0];\n\t\ta-\u003einfo-\u003eoptions \u003d i[1];\n#if defined(LWS_WITH_SERVER)\n\t\ta-\u003einfo-\u003eserver_string \u003d ss;\n#endif\n\t\ta-\u003einfo-\u003etimeout_secs \u003d i[3];\n\n\t\ta-\u003einfo-\u003eprotocols \u003d a-\u003eprotocols;\n\t\ta-\u003einfo-\u003epprotocols \u003d a-\u003epprotocols;\n#if defined(LWS_ROLE_WS)\n\t\ta-\u003einfo-\u003eextensions \u003d a-\u003eextensions;\n#endif\n#if defined(LWS_WITH_TLS)\n#if defined(LWS_WITH_CLIENT)\n\t\ta-\u003einfo-\u003eclient_ssl_cipher_list \u003d \u0022ECDHE-ECDSA-AES256-GCM-SHA384:\u0022\n\t\t\t\u0022ECDHE-RSA-AES256-GCM-SHA384:\u0022\n\t\t\t\u0022DHE-RSA-AES256-GCM-SHA384:\u0022\n\t\t\t\u0022ECDHE-RSA-AES256-SHA384:\u0022\n\t\t\t\u0022HIGH:!aNULL:!eNULL:!EXPORT:\u0022\n\t\t\t\u0022!DES:!MD5:!PSK:!RC4:!HMAC_SHA1:\u0022\n\t\t\t\u0022!SHA1:!DHE-RSA-AES128-GCM-SHA256:\u0022\n\t\t\t\u0022!DHE-RSA-AES128-SHA256:\u0022\n\t\t\t\u0022!AES128-GCM-SHA256:\u0022\n\t\t\t\u0022!AES128-SHA256:\u0022\n\t\t\t\u0022!DHE-RSA-AES256-SHA256:\u0022\n\t\t\t\u0022!AES256-GCM-SHA384:\u0022\n\t\t\t\u0022!AES256-SHA256\u0022;\n#endif\n#if defined(LWS_WITH_SERVER)\n\t\ta-\u003einfo-\u003essl_cipher_list \u003d \u0022ECDHE-ECDSA-AES256-GCM-SHA384:\u0022\n\t\t\t\t \u0022ECDHE-RSA-AES256-GCM-SHA384:\u0022\n\t\t\t\t \u0022DHE-RSA-AES256-GCM-SHA384:\u0022\n\t\t\t\t \u0022ECDHE-RSA-AES256-SHA384:\u0022\n\t\t\t\t \u0022HIGH:!aNULL:!eNULL:!EXPORT:\u0022\n\t\t\t\t \u0022!DES:!MD5:!PSK:!RC4:!HMAC_SHA1:\u0022\n\t\t\t\t \u0022!SHA1:!DHE-RSA-AES128-GCM-SHA256:\u0022\n\t\t\t\t \u0022!DHE-RSA-AES128-SHA256:\u0022\n\t\t\t\t \u0022!AES128-GCM-SHA256:\u0022\n\t\t\t\t \u0022!AES128-SHA256:\u0022\n\t\t\t\t \u0022!DHE-RSA-AES256-SHA256:\u0022\n\t\t\t\t \u0022!AES256-GCM-SHA384:\u0022\n\t\t\t\t \u0022!AES256-SHA256\u0022;\n#endif\n#endif\n\t\ta-\u003einfo-\u003ekeepalive_timeout \u003d 5;\n\t}\n\n\tif (reason \u003d\u003d LEJPCB_OBJECT_START \u0026\u0026\n\t ctx-\u003epath_match \u003d\u003d LEJPVP_MOUNTS + 1) {\n\t\ta-\u003efresh_mount \u003d 1;\n\t\tmemset(\u0026a-\u003em, 0, sizeof(a-\u003em));\n\t}\n\n\t/* this catches, eg, vhosts[].ws-protocols[].xxx-protocol */\n\tif (reason \u003d\u003d LEJPCB_OBJECT_START \u0026\u0026\n\t ctx-\u003epath_match \u003d\u003d LEJPVP_PROTOCOL_NAME + 1) {\n\t\ta-\u003epvo \u003d lwsws_align(a);\n\t\ta-\u003ep +\u003d sizeof(*a-\u003epvo);\n\n\t\tn \u003d lejp_get_wildcard(ctx, 0, a-\u003ep, lws_ptr_diff(a-\u003eend, a-\u003ep));\n\t\t/* ie, enable this protocol, no options yet */\n\t\ta-\u003epvo-\u003enext \u003d a-\u003einfo-\u003epvo;\n\t\ta-\u003einfo-\u003epvo \u003d a-\u003epvo;\n\t\ta-\u003epvo-\u003ename \u003d a-\u003ep;\n\t\tlwsl_info(\u0022 adding protocol %s\u005cn\u0022, a-\u003ep);\n\t\ta-\u003ep +\u003d n;\n\t\ta-\u003epvo-\u003evalue \u003d a-\u003ep;\n\t\ta-\u003epvo-\u003eoptions \u003d NULL;\n\t\tgoto dostring;\n\t}\n\n\t/* this catches, eg, vhosts[].headers[].xxx */\n\tif ((reason \u003d\u003d LEJPCB_VAL_STR_END || reason \u003d\u003d LEJPCB_VAL_STR_CHUNK) \u0026\u0026\n\t ctx-\u003epath_match \u003d\u003d LEJPVP_HEADERS_NAME + 1) {\n\n\t\tif (!a-\u003echunk) {\n\t\t\theaders \u003d lwsws_align(a);\n\t\t\ta-\u003ep +\u003d sizeof(*headers);\n\n\t\t\tn \u003d lejp_get_wildcard(ctx, 0, a-\u003ep,\n\t\t\t\t\tlws_ptr_diff(a-\u003eend, a-\u003ep));\n\t\t\t/* ie, add this header */\n\t\t\theaders-\u003enext \u003d a-\u003einfo-\u003eheaders;\n\t\t\ta-\u003einfo-\u003eheaders \u003d headers;\n\t\t\theaders-\u003ename \u003d a-\u003ep;\n\n\t\t\tlwsl_notice(\u0022 adding header %s\u003d%s\u005cn\u0022, a-\u003ep, ctx-\u003ebuf);\n\t\t\ta-\u003ep +\u003d n - 1;\n\t\t\t*(a-\u003ep++) \u003d ':';\n\t\t\tif (a-\u003ep \u003c a-\u003eend)\n\t\t\t\t*(a-\u003ep++) \u003d '\u005c0';\n\t\t\telse\n\t\t\t\t*(a-\u003ep - 1) \u003d '\u005c0';\n\t\t\theaders-\u003evalue \u003d a-\u003ep;\n\t\t\theaders-\u003eoptions \u003d NULL;\n\t\t}\n\t\ta-\u003echunk \u003d reason \u003d\u003d LEJPCB_VAL_STR_CHUNK;\n\t\tgoto dostring;\n\t}\n\n\tif (reason \u003d\u003d LEJPCB_OBJECT_END \u0026\u0026\n\t (ctx-\u003epath_match \u003d\u003d LEJPVP + 1 || !ctx-\u003epath[0]) \u0026\u0026\n\t a-\u003evalid) {\n\n\t\tstruct lws_vhost *vhost;\n\n\t\t//lwsl_notice(\u0022%s\u005cn\u0022, ctx-\u003epath);\n\t\tif (!a-\u003einfo-\u003eport \u0026\u0026\n\t\t !(a-\u003einfo-\u003eoptions \u0026 LWS_SERVER_OPTION_UNIX_SOCK)) {\n\t\t\tlwsl_err(\u0022Port required (eg, 443)\u005cn\u0022);\n\t\t\treturn 1;\n\t\t}\n\t\ta-\u003evalid \u003d 0;\n\t\ta-\u003einfo-\u003emounts \u003d a-\u003ehead;\n\n\t\tvhost \u003d lws_create_vhost(a-\u003econtext, a-\u003einfo);\n\t\tif (!vhost) {\n\t\t\tlwsl_err(\u0022Failed to create vhost %s\u005cn\u0022,\n\t\t\t\t a-\u003einfo-\u003evhost_name);\n\t\t\treturn 1;\n\t\t}\n\t\ta-\u003eany_vhosts \u003d 1;\n\n\t\tif (a-\u003ereject_ws_with_no_protocol) {\n\t\t\ta-\u003ereject_ws_with_no_protocol \u003d 0;\n\n\t\t\tvhost-\u003edefault_protocol_index \u003d 255;\n\t\t}\n\n#if defined(LWS_WITH_TLS) \u0026\u0026 defined(LWS_WITH_CLIENT)\n\t\tif (a-\u003eenable_client_ssl) {\n\t\t\tconst char *cert_filepath \u003d\n\t\t\t\t\ta-\u003einfo-\u003eclient_ssl_cert_filepath;\n\t\t\tconst char *private_key_filepath \u003d\n\t\t\t\t a-\u003einfo-\u003eclient_ssl_private_key_filepath;\n\t\t\tconst char *ca_filepath \u003d\n\t\t\t\t\ta-\u003einfo-\u003eclient_ssl_ca_filepath;\n\t\t\tconst char *cipher_list \u003d\n\t\t\t\t\ta-\u003einfo-\u003eclient_ssl_cipher_list;\n\n\t\t\tmemset(a-\u003einfo, 0, sizeof(*a-\u003einfo));\n\t\t\ta-\u003einfo-\u003eclient_ssl_cert_filepath \u003d cert_filepath;\n\t\t\ta-\u003einfo-\u003eclient_ssl_private_key_filepath \u003d\n\t\t\t\t\t\t\tprivate_key_filepath;\n\t\t\ta-\u003einfo-\u003eclient_ssl_ca_filepath \u003d ca_filepath;\n\t\t\ta-\u003einfo-\u003eclient_ssl_cipher_list \u003d cipher_list;\n\t\t\ta-\u003einfo-\u003eoptions \u003d LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT;\n\t\t\tlws_init_vhost_client_ssl(a-\u003einfo, vhost);\n\t\t}\n#endif\n\n\t\treturn 0;\n\t}\n\n\tif (reason \u003d\u003d LEJPCB_OBJECT_END \u0026\u0026\n\t ctx-\u003epath_match \u003d\u003d LEJPVP_MOUNTS + 1) {\n\t\tstatic const char * const mount_protocols[] \u003d {\n\t\t\t\u0022http://\u0022,\n\t\t\t\u0022https://\u0022,\n\t\t\t\u0022file://\u0022,\n\t\t\t\u0022cgi://\u0022,\n\t\t\t\u0022\u003ehttp://\u0022,\n\t\t\t\u0022\u003ehttps://\u0022,\n\t\t\t\u0022callback://\u0022,\n\t\t\t\u0022gzip://\u0022,\n\t\t};\n\n\t\tif (!a-\u003efresh_mount)\n\t\t\treturn 0;\n\n\t\tif (!a-\u003em.mountpoint || !a-\u003em.origin) {\n\t\t\tlwsl_err(\u0022mountpoint and origin required\u005cn\u0022);\n\t\t\treturn 1;\n\t\t}\n\t\tlwsl_debug(\u0022adding mount %s\u005cn\u0022, a-\u003em.mountpoint);\n\t\tm \u003d lwsws_align(a);\n\t\tmemcpy(m, \u0026a-\u003em, sizeof(*m));\n\t\tif (a-\u003elast)\n\t\t\ta-\u003elast-\u003emount_next \u003d m;\n\n\t\tfor (n \u003d 0; n \u003c (int)LWS_ARRAY_SIZE(mount_protocols); n++)\n\t\t\tif (!strncmp(a-\u003em.origin, mount_protocols[n],\n\t\t\t strlen(mount_protocols[n]))) {\n\t\t\t\tlwsl_info(\u0022----%s\u005cn\u0022, a-\u003em.origin);\n\t\t\t\tm-\u003eorigin_protocol \u003d (uint8_t)(unsigned int)n;\n\t\t\t\tm-\u003eorigin \u003d a-\u003em.origin +\n\t\t\t\t\t strlen(mount_protocols[n]);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\tif (n \u003d\u003d (int)LWS_ARRAY_SIZE(mount_protocols)) {\n\t\t\tlwsl_err(\u0022unsupported protocol:// %s\u005cn\u0022, a-\u003em.origin);\n\t\t\treturn 1;\n\t\t}\n\n\t\ta-\u003ep +\u003d sizeof(*m);\n\t\tif (!a-\u003ehead)\n\t\t\ta-\u003ehead \u003d m;\n\n\t\ta-\u003elast \u003d m;\n\t\ta-\u003efresh_mount \u003d 0;\n\t}\n\n\t/* we only match on the prepared path strings */\n\tif (!(reason \u0026 LEJP_FLAG_CB_IS_VALUE) || !ctx-\u003epath_match)\n\t\treturn 0;\n\n\tswitch (ctx-\u003epath_match - 1) {\n\tcase LEJPVP_NAME:\n\t\ta-\u003einfo-\u003evhost_name \u003d a-\u003ep;\n\t\tbreak;\n\tcase LEJPVP_PORT:\n\t\ta-\u003einfo-\u003eport \u003d atoi(ctx-\u003ebuf);\n\t\treturn 0;\n\tcase LEJPVP_INTERFACE:\n\t\ta-\u003einfo-\u003eiface \u003d a-\u003ep;\n\t\tbreak;\n\tcase LEJPVP_UNIXSKT:\n\t\tif (arg_to_bool(ctx-\u003ebuf))\n\t\t\ta-\u003einfo-\u003eoptions |\u003d (uint64_t)LWS_SERVER_OPTION_UNIX_SOCK;\n\t\telse\n\t\t\ta-\u003einfo-\u003eoptions \u0026\u003d (uint64_t)~(LWS_SERVER_OPTION_UNIX_SOCK);\n\t\treturn 0;\n\tcase LEJPVP_UNIXSKT_PERMS:\n\t\ta-\u003einfo-\u003eunix_socket_perms \u003d a-\u003ep;\n\t\tbreak;\n\tcase LEJPVP_STS:\n\t\tif (arg_to_bool(ctx-\u003ebuf))\n\t\t\ta-\u003einfo-\u003eoptions |\u003d (uint64_t)LWS_SERVER_OPTION_STS;\n\t\telse\n\t\t\ta-\u003einfo-\u003eoptions \u0026\u003d (uint64_t)~(LWS_SERVER_OPTION_STS);\n\t\treturn 0;\n#if defined(LWS_WITH_TLS)\n\tcase LEJPVP_HOST_SSL_KEY:\n\t\ta-\u003einfo-\u003essl_private_key_filepath \u003d a-\u003ep;\n\t\tbreak;\n\tcase LEJPVP_HOST_SSL_CERT:\n\t\ta-\u003einfo-\u003essl_cert_filepath \u003d a-\u003ep;\n\t\tbreak;\n\tcase LEJPVP_HOST_SSL_CA:\n\t\ta-\u003einfo-\u003essl_ca_filepath \u003d a-\u003ep;\n\t\tbreak;\n#endif\n\tcase LEJPVP_ACCESS_LOG:\n\t\ta-\u003einfo-\u003elog_filepath \u003d a-\u003ep;\n\t\tbreak;\n\tcase LEJPVP_MOUNTPOINT:\n\t\ta-\u003em.mountpoint \u003d a-\u003ep;\n\t\ta-\u003em.mountpoint_len \u003d (unsigned char)strlen(ctx-\u003ebuf);\n\t\tbreak;\n\tcase LEJPVP_ORIGIN:\n\t\tif (!strncmp(ctx-\u003ebuf, \u0022callback://\u0022, 11))\n\t\t\ta-\u003em.protocol \u003d a-\u003ep + 11;\n\n\t\tif (!a-\u003em.origin)\n\t\t\ta-\u003em.origin \u003d a-\u003ep;\n\t\tbreak;\n\tcase LEJPVP_DEFAULT:\n\t\ta-\u003em.def \u003d a-\u003ep;\n\t\tbreak;\n\tcase LEJPVP_DEFAULT_AUTH_MASK:\n\t\ta-\u003em.auth_mask \u003d (unsigned int)atoi(ctx-\u003ebuf);\n\t\treturn 0;\n\tcase LEJPVP_MOUNT_CACHE_MAX_AGE:\n\t\ta-\u003em.cache_max_age \u003d atoi(ctx-\u003ebuf);\n\t\treturn 0;\n\tcase LEJPVP_MOUNT_CACHE_REUSE:\n\t\ta-\u003em.cache_reusable \u003d !!arg_to_bool(ctx-\u003ebuf);\n\t\treturn 0;\n\tcase LEJPVP_MOUNT_CACHE_REVALIDATE:\n\t\ta-\u003em.cache_revalidate \u003d !!arg_to_bool(ctx-\u003ebuf);\n\t\treturn 0;\n\tcase LEJPVP_MOUNT_CACHE_NO:\n\t\ta-\u003em.cache_no \u003d !!arg_to_bool(ctx-\u003ebuf);\n\t\treturn 0;\n\tcase LEJPVP_MOUNT_CACHE_INTERMEDIARIES:\n\t\ta-\u003em.cache_intermediaries \u003d !!arg_to_bool(ctx-\u003ebuf);;\n\t\treturn 0;\n\tcase LEJPVP_MOUNT_BASIC_AUTH:\n#if defined(LWS_WITH_HTTP_BASIC_AUTH)\n\t\ta-\u003em.basic_auth_login_file \u003d a-\u003ep;\n#endif\n\t\tbreak;\n\tcase LEJPVP_CGI_TIMEOUT:\n\t\ta-\u003em.cgi_timeout \u003d atoi(ctx-\u003ebuf);\n\t\treturn 0;\n\tcase LWJPVP_FO_LISTEN_QUEUE:\n\t\ta-\u003einfo-\u003efo_listen_queue \u003d atoi(ctx-\u003ebuf);\n\t\treturn 0;\n\tcase LEJPVP_KEEPALIVE_TIMEOUT:\n\t\ta-\u003einfo-\u003ekeepalive_timeout \u003d atoi(ctx-\u003ebuf);\n\t\treturn 0;\n#if defined(LWS_WITH_TLS)\n#if defined(LWS_WITH_CLIENT)\n\tcase LEJPVP_CLIENT_CIPHERS:\n\t\ta-\u003einfo-\u003eclient_ssl_cipher_list \u003d a-\u003ep;\n\t\tbreak;\n\tcase LEJPVP_CLIENT_TLS13_CIPHERS:\n\t\ta-\u003einfo-\u003eclient_tls_1_3_plus_cipher_list \u003d a-\u003ep;\n\t\tbreak;\n#endif\n\n\tcase LEJPVP_CIPHERS:\n\t\ta-\u003einfo-\u003essl_cipher_list \u003d a-\u003ep;\n\t\tbreak;\n\tcase LEJPVP_TLS13_CIPHERS:\n\t\ta-\u003einfo-\u003etls1_3_plus_cipher_list \u003d a-\u003ep;\n\t\tbreak;\n\tcase LEJPVP_ECDH_CURVE:\n\t\ta-\u003einfo-\u003eecdh_curve \u003d a-\u003ep;\n\t\tbreak;\n#endif\n\tcase LEJPVP_PMO:\n\tcase LEJPVP_CGI_ENV:\n\t\tmp_cgienv \u003d lwsws_align(a);\n\t\ta-\u003ep +\u003d sizeof(*a-\u003em.cgienv);\n\n\t\tmp_cgienv-\u003enext \u003d a-\u003em.cgienv;\n\t\ta-\u003em.cgienv \u003d mp_cgienv;\n\n\t\tn \u003d lejp_get_wildcard(ctx, 0, a-\u003ep, lws_ptr_diff(a-\u003eend, a-\u003ep));\n\t\tmp_cgienv-\u003ename \u003d a-\u003ep;\n\t\ta-\u003ep +\u003d n;\n\t\tmp_cgienv-\u003evalue \u003d a-\u003ep;\n\t\tmp_cgienv-\u003eoptions \u003d NULL;\n\t\t//lwsl_notice(\u0022 adding pmo / cgi-env '%s' \u003d '%s'\u005cn\u0022,\n\t\t//\t\tmp_cgienv-\u003ename, mp_cgienv-\u003evalue);\n\t\tgoto dostring;\n\n\tcase LEJPVP_PROTOCOL_NAME_OPT:\n\t\t/* this catches, eg,\n\t\t * vhosts[].ws-protocols[].xxx-protocol.yyy-option\n\t\t * ie, these are options attached to a protocol with { }\n\t\t */\n\t\tpvo \u003d lwsws_align(a);\n\t\ta-\u003ep +\u003d sizeof(*a-\u003epvo);\n\n\t\tn \u003d lejp_get_wildcard(ctx, 1, a-\u003ep, lws_ptr_diff(a-\u003eend, a-\u003ep));\n\t\t/* ie, enable this protocol, no options yet */\n\t\tpvo-\u003enext \u003d a-\u003epvo-\u003eoptions;\n\t\ta-\u003epvo-\u003eoptions \u003d pvo;\n\t\tpvo-\u003ename \u003d a-\u003ep;\n\t\ta-\u003ep +\u003d n;\n\t\tpvo-\u003evalue \u003d a-\u003ep;\n\t\tpvo-\u003eoptions \u003d NULL;\n\t\tbreak;\n\n\tcase LEJPVP_MOUNT_EXTRA_MIMETYPES:\n\t\ta-\u003epvo_em \u003d lwsws_align(a);\n\t\ta-\u003ep +\u003d sizeof(*a-\u003epvo_em);\n\n\t\tn \u003d lejp_get_wildcard(ctx, 0, a-\u003ep, lws_ptr_diff(a-\u003eend, a-\u003ep));\n\t\t/* ie, enable this protocol, no options yet */\n\t\ta-\u003epvo_em-\u003enext \u003d a-\u003em.extra_mimetypes;\n\t\ta-\u003em.extra_mimetypes \u003d a-\u003epvo_em;\n\t\ta-\u003epvo_em-\u003ename \u003d a-\u003ep;\n\t\tlwsl_notice(\u0022 + extra-mimetypes %s -\u003e %s\u005cn\u0022, a-\u003ep, ctx-\u003ebuf);\n\t\ta-\u003ep +\u003d n;\n\t\ta-\u003epvo_em-\u003evalue \u003d a-\u003ep;\n\t\ta-\u003epvo_em-\u003eoptions \u003d NULL;\n\t\tbreak;\n\n\tcase LEJPVP_MOUNT_INTERPRET:\n\t\ta-\u003epvo_int \u003d lwsws_align(a);\n\t\ta-\u003ep +\u003d sizeof(*a-\u003epvo_int);\n\n\t\tn \u003d lejp_get_wildcard(ctx, 0, a-\u003ep, lws_ptr_diff(a-\u003eend, a-\u003ep));\n\t\t/* ie, enable this protocol, no options yet */\n\t\ta-\u003epvo_int-\u003enext \u003d a-\u003em.interpret;\n\t\ta-\u003em.interpret \u003d a-\u003epvo_int;\n\t\ta-\u003epvo_int-\u003ename \u003d a-\u003ep;\n\t\tlwsl_notice(\u0022 adding interpret %s -\u003e %s\u005cn\u0022, a-\u003ep,\n\t\t\t ctx-\u003ebuf);\n\t\ta-\u003ep +\u003d n;\n\t\ta-\u003epvo_int-\u003evalue \u003d a-\u003ep;\n\t\ta-\u003epvo_int-\u003eoptions \u003d NULL;\n\t\tbreak;\n\n\tcase LEJPVP_ENABLE_CLIENT_SSL:\n\t\ta-\u003eenable_client_ssl \u003d !!arg_to_bool(ctx-\u003ebuf);\n\t\treturn 0;\n#if defined(LWS_WITH_TLS) \u0026\u0026 defined(LWS_WITH_CLIENT)\n\tcase LEJPVP_CLIENT_SSL_KEY:\n\t\ta-\u003einfo-\u003eclient_ssl_private_key_filepath \u003d a-\u003ep;\n\t\tbreak;\n\tcase LEJPVP_CLIENT_SSL_CERT:\n\t\ta-\u003einfo-\u003eclient_ssl_cert_filepath \u003d a-\u003ep;\n\t\tbreak;\n\tcase LEJPVP_CLIENT_SSL_CA:\n\t\ta-\u003einfo-\u003eclient_ssl_ca_filepath \u003d a-\u003ep;\n\t\tbreak;\n#endif\n\n\tcase LEJPVP_NOIPV6:\n\t\tset_reset_flag(\u0026a-\u003einfo-\u003eoptions, ctx-\u003ebuf,\n\t\t\t LWS_SERVER_OPTION_DISABLE_IPV6);\n\t\treturn 0;\n\n\tcase LEJPVP_FLAG_ONLYRAW:\n\t\tset_reset_flag(\u0026a-\u003einfo-\u003eoptions, ctx-\u003ebuf,\n\t\t\t LWS_SERVER_OPTION_ADOPT_APPLY_LISTEN_ACCEPT_CONFIG);\n\t\treturn 0;\n\n\tcase LEJPVP_IPV6ONLY:\n\t\ta-\u003einfo-\u003eoptions |\u003d LWS_SERVER_OPTION_IPV6_V6ONLY_MODIFY;\n\t\tset_reset_flag(\u0026a-\u003einfo-\u003eoptions, ctx-\u003ebuf,\n\t\t\t LWS_SERVER_OPTION_IPV6_V6ONLY_VALUE);\n\t\treturn 0;\n\n\tcase LEJPVP_FLAG_CLIENT_CERT_REQUIRED:\n\t\tif (arg_to_bool(ctx-\u003ebuf))\n\t\t\ta-\u003einfo-\u003eoptions |\u003d\n\t\t\t LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT;\n\t\treturn 0;\n\n\tcase LEJPVP_IGNORE_MISSING_CERT:\n\t\tset_reset_flag(\u0026a-\u003einfo-\u003eoptions, ctx-\u003ebuf,\n\t\t\t\tLWS_SERVER_OPTION_IGNORE_MISSING_CERT);\n\t\treturn 0;\n\n\tcase LEJPVP_FLAG_STRICT_HOST_CHECK:\n\t\tset_reset_flag(\u0026a-\u003einfo-\u003eoptions, ctx-\u003ebuf,\n\t\t\tLWS_SERVER_OPTION_VHOST_UPG_STRICT_HOST_CHECK);\n\t\treturn 0;\n\n\tcase LEJPVP_ERROR_DOCUMENT_404:\n\t\ta-\u003einfo-\u003eerror_document_404 \u003d a-\u003ep;\n\t\tbreak;\n\n#if defined(LWS_WITH_TLS)\n\tcase LEJPVP_SSL_OPTION_SET:\n\t\ta-\u003einfo-\u003essl_options_set |\u003d atol(ctx-\u003ebuf);\n\t\treturn 0;\n\tcase LEJPVP_SSL_OPTION_CLEAR:\n\t\ta-\u003einfo-\u003essl_options_clear |\u003d atol(ctx-\u003ebuf);\n\t\treturn 0;\n\n#if defined(LWS_WITH_CLIENT)\n\tcase LEJPVP_SSL_CLIENT_OPTION_SET:\n\t\ta-\u003einfo-\u003essl_client_options_set |\u003d atol(ctx-\u003ebuf);\n\t\treturn 0;\n\tcase LEJPVP_SSL_CLIENT_OPTION_CLEAR:\n\t\ta-\u003einfo-\u003essl_client_options_clear |\u003d atol(ctx-\u003ebuf);\n\t\treturn 0;\n#endif\n\n\tcase LEJPVP_ALPN:\n\t\ta-\u003einfo-\u003ealpn \u003d a-\u003ep;\n\t\tbreak;\n#endif\n\n\tcase LEJPVP_LISTEN_ACCEPT_ROLE:\n\t\ta-\u003einfo-\u003elisten_accept_role \u003d a-\u003ep;\n\t\tbreak;\n\tcase LEJPVP_LISTEN_ACCEPT_PROTOCOL:\n\t\ta-\u003einfo-\u003elisten_accept_protocol \u003d a-\u003ep;\n\t\tbreak;\n\n\tcase LEJPVP_FLAG_APPLY_LISTEN_ACCEPT:\n\t\tset_reset_flag(\u0026a-\u003einfo-\u003eoptions, ctx-\u003ebuf,\n\t\t\tLWS_SERVER_OPTION_ADOPT_APPLY_LISTEN_ACCEPT_CONFIG);\n\t\treturn 0;\n\tcase LEJPVP_FLAG_FALLBACK_LISTEN_ACCEPT:\n\t\tlwsl_notice(\u0022vh %s: LEJPVP_FLAG_FALLBACK_LISTEN_ACCEPT: %s\u005cn\u0022,\n\t\t\t a-\u003einfo-\u003evhost_name, ctx-\u003ebuf);\n\t\tset_reset_flag(\u0026a-\u003einfo-\u003eoptions, ctx-\u003ebuf,\n\t\t LWS_SERVER_OPTION_FALLBACK_TO_APPLY_LISTEN_ACCEPT_CONFIG);\n\t\treturn 0;\n\tcase LEJPVP_FLAG_ALLOW_NON_TLS:\n\t\tset_reset_flag(\u0026a-\u003einfo-\u003eoptions, ctx-\u003ebuf,\n\t\t\t LWS_SERVER_OPTION_ALLOW_NON_SSL_ON_SSL_PORT);\n\t\treturn 0;\n\tcase LEJPVP_FLAG_REDIRECT_HTTP:\n\t\tset_reset_flag(\u0026a-\u003einfo-\u003eoptions, ctx-\u003ebuf,\n\t\t\t LWS_SERVER_OPTION_REDIRECT_HTTP_TO_HTTPS);\n\t\treturn 0;\n\tcase LEJPVP_FLAG_ALLOW_HTTP_ON_HTTPS:\n\t\tset_reset_flag(\u0026a-\u003einfo-\u003eoptions, ctx-\u003ebuf,\n\t\t\t LWS_SERVER_OPTION_ALLOW_HTTP_ON_HTTPS_LISTENER);\n\t\treturn 0;\n\n\tcase LEJPVP_FLAG_DISABLE_NO_PROTOCOL_WS_UPGRADES:\n\t\ta-\u003ereject_ws_with_no_protocol \u003d 1;\n\t\treturn 0;\n\n\tcase LEJPVP_FLAG_H2_HALF_CLOSED_LONG_POLL:\n\t\tset_reset_flag(\u0026a-\u003einfo-\u003eoptions, ctx-\u003ebuf,\n\t\t\t\tLWS_SERVER_OPTION_VH_H2_HALF_CLOSED_LONG_POLL);\n\t\treturn 0;\n\n\tdefault:\n\t\treturn 0;\n\t}\n\ndostring:\n\tp \u003d ctx-\u003ebuf;\n\tp[LEJP_STRING_CHUNK] \u003d '\u005c0';\n\tp1 \u003d strstr(p, ESC_INSTALL_DATADIR);\n\tif (p1) {\n\t\tn \u003d lws_ptr_diff(p1, p);\n\t\tif (n \u003e a-\u003eend - a-\u003ep)\n\t\t\tn \u003d lws_ptr_diff(a-\u003eend, a-\u003ep);\n\t\tlws_strncpy(a-\u003ep, p, (unsigned int)n + 1u);\n\t\ta-\u003ep +\u003d n;\n\t\ta-\u003ep +\u003d lws_snprintf(a-\u003ep, lws_ptr_diff_size_t(a-\u003eend, a-\u003ep), \u0022%s\u0022,\n\t\t\t\t LWS_INSTALL_DATADIR);\n\t\tp +\u003d n + (int)strlen(ESC_INSTALL_DATADIR);\n\t}\n\n\ta-\u003ep +\u003d lws_snprintf(a-\u003ep, lws_ptr_diff_size_t(a-\u003eend, a-\u003ep), \u0022%s\u0022, p);\n\tif (reason \u003d\u003d LEJPCB_VAL_STR_END)\n\t\t*(a-\u003ep)++ \u003d '\u005c0';\n\n\treturn 0;\n}\n\n/*\n * returns 0 \u003d OK, 1 \u003d can't open, 2 \u003d parsing error\n */\n\nstatic int\nlwsws_get_config(void *user, const char *f, const char * const *paths,\n\t\t int count_paths, lejp_callback cb)\n{\n\tunsigned char buf[128];\n\tstruct lejp_ctx ctx;\n\tint n, m \u003d 0, fd;\n\n\tmemset(\u0026ctx, 0, sizeof(ctx));\n\n\tfd \u003d lws_open(f, O_RDONLY);\n\tif (fd \u003c 0) {\n\t\tlwsl_err(\u0022Cannot open %s\u005cn\u0022, f);\n\t\treturn 2;\n\t}\n\tlwsl_info(\u0022%s: %s\u005cn\u0022, __func__, f);\n\tlejp_construct(\u0026ctx, cb, user, paths, (uint8_t)(unsigned int)count_paths);\n\n\tdo {\n\t\tn \u003d (int)read(fd, buf, sizeof(buf));\n\t\tif (!n)\n\t\t\tbreak;\n\n\t\tm \u003d lejp_parse(\u0026ctx, buf, n);\n\t} while (m \u003d\u003d LEJP_CONTINUE);\n\n\tclose(fd);\n\tn \u003d (int32_t)ctx.line;\n\tlejp_destruct(\u0026ctx);\n\n\tif (m \u003c 0) {\n\t\tlwsl_err(\u0022%s(%u): parsing error %d: %s\u005cn\u0022, f, n, m,\n\t\t\t lejp_error_to_string(m));\n\t\treturn 2;\n\t}\n\n\treturn 0;\n}\n\nstruct lws_dir_args {\n\tvoid *user;\n\tconst char * const *paths;\n\tint count_paths;\n\tlejp_callback cb;\n};\n\nstatic int\nlwsws_get_config_d_cb(const char *dirpath, void *user,\n\t\t struct lws_dir_entry *lde)\n{\n\tstruct lws_dir_args *da \u003d (struct lws_dir_args *)user;\n\tchar path[256];\n\n\tif (lde-\u003etype !\u003d LDOT_FILE \u0026\u0026 lde-\u003etype !\u003d LDOT_UNKNOWN /* ZFS */)\n\t\treturn 0;\n\n\tlws_snprintf(path, sizeof(path) - 1, \u0022%s/%s\u0022, dirpath, lde-\u003ename);\n\n\treturn lwsws_get_config(da-\u003euser, path, da-\u003epaths,\n\t\t\t\tda-\u003ecount_paths, da-\u003ecb);\n}\n\nint\nlwsws_get_config_globals(struct lws_context_creation_info *info, const char *d,\n\t\t\t char **cs, int *len)\n{\n\tstruct lws_dir_args da;\n\tstruct jpargs a;\n#if defined(LWS_WITH_PLUGINS)\n\tconst char * const *old \u003d info-\u003eplugin_dirs;\n#endif\n\tchar dd[128];\n\n\tmemset(\u0026a, 0, sizeof(a));\n\n\ta.info \u003d info;\n\ta.p \u003d *cs;\n\ta.end \u003d (a.p + *len) - 1;\n\ta.valid \u003d 0;\n\n\tlwsws_align(\u0026a);\n#if defined(LWS_WITH_PLUGINS)\n\tinfo-\u003eplugin_dirs \u003d (void *)a.p;\n#endif\n\ta.plugin_dirs \u003d (void *)a.p; /* writeable version */\n\ta.p +\u003d MAX_PLUGIN_DIRS * sizeof(void *);\n\n#if defined(LWS_WITH_PLUGINS)\n\t/* copy any default paths */\n\n\twhile (old \u0026\u0026 *old) {\n\t\ta.plugin_dirs[a.count_plugin_dirs++] \u003d *old;\n\t\told++;\n\t}\n#endif\n\n\tlws_snprintf(dd, sizeof(dd) - 1, \u0022%s/conf\u0022, d);\n\tif (lwsws_get_config(\u0026a, dd, paths_global,\n\t\t\t LWS_ARRAY_SIZE(paths_global), lejp_globals_cb) \u003e 1)\n\t\treturn 1;\n\tlws_snprintf(dd, sizeof(dd) - 1, \u0022%s/conf.d\u0022, d);\n\n\tda.user \u003d \u0026a;\n\tda.paths \u003d paths_global;\n\tda.count_paths \u003d LWS_ARRAY_SIZE(paths_global),\n\tda.cb \u003d lejp_globals_cb;\n\n\tif (lws_dir(dd, \u0026da, lwsws_get_config_d_cb) \u003e 1)\n\t\treturn 1;\n\n\ta.plugin_dirs[a.count_plugin_dirs] \u003d NULL;\n\n\t*cs \u003d a.p;\n\t*len \u003d lws_ptr_diff(a.end, a.p);\n\n\treturn 0;\n}\n\nint\nlwsws_get_config_vhosts(struct lws_context *context,\n\t\t\tstruct lws_context_creation_info *info, const char *d,\n\t\t\tchar **cs, int *len)\n{\n\tstruct lws_dir_args da;\n\tstruct jpargs a;\n\tchar dd[128];\n\n\tmemset(\u0026a, 0, sizeof(a));\n\n\ta.info \u003d info;\n\ta.p \u003d *cs;\n\ta.end \u003d a.p + *len;\n\ta.valid \u003d 0;\n\ta.context \u003d context;\n\ta.protocols \u003d info-\u003eprotocols;\n\ta.pprotocols \u003d info-\u003epprotocols;\n#if defined(LWS_ROLE_WS)\n\ta.extensions \u003d info-\u003eextensions;\n#endif\n\n\tlws_snprintf(dd, sizeof(dd) - 1, \u0022%s/conf\u0022, d);\n\tif (lwsws_get_config(\u0026a, dd, paths_vhosts,\n\t\t\t LWS_ARRAY_SIZE(paths_vhosts), lejp_vhosts_cb) \u003e 1)\n\t\treturn 1;\n\tlws_snprintf(dd, sizeof(dd) - 1, \u0022%s/conf.d\u0022, d);\n\n\tda.user \u003d \u0026a;\n\tda.paths \u003d paths_vhosts;\n\tda.count_paths \u003d LWS_ARRAY_SIZE(paths_vhosts),\n\tda.cb \u003d lejp_vhosts_cb;\n\n\tif (lws_dir(dd, \u0026da, lwsws_get_config_d_cb) \u003e 1)\n\t\treturn 1;\n\n\t*cs \u003d a.p;\n\t*len \u003d lws_ptr_diff(a.end, a.p);\n\n\tif (!a.any_vhosts) {\n\t\tlwsl_err(\u0022Need at least one vhost\u005cn\u0022);\n\t\treturn 1;\n\t}\n\n//\tlws_finalize_startup(context);\n\n\treturn 0;\n}\n","s":{"c":1711650377,"u": 654}} ],"g": 4007,"chitpc": 0,"ehitpc": 0,"indexed":0 , "ab": 1, "si": 0, "db":0, "di":0, "sat":0, "lfc": "0000"}