libwebsockets
Lightweight C library for HTML5 websockets
lws-context-vhost.h
1 /*
2  * libwebsockets - small server side websockets and web server implementation
3  *
4  * Copyright (C) 2010-2018 Andy Green <andy@warmcat.com>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation:
9  * version 2.1 of the License.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19  * MA 02110-1301 USA
20  *
21  * included from libwebsockets.h
22  */
23 
38 
39 /*
40  * NOTE: These public enums are part of the abi. If you want to add one,
41  * add it at where specified so existing users are unaffected.
42  */
43 
47  (1 << 12),
54  (1 << 12),
61  LWS_SERVER_OPTION_LIBEV = (1 << 4),
72  LWS_SERVER_OPTION_SSL_ECDH = (1 << 9) |
73  (1 << 12),
75  LWS_SERVER_OPTION_LIBUV = (1 << 10),
78  (1 << 12),
93  LWS_SERVER_OPTION_UNIX_SOCK = (1 << 14),
95  LWS_SERVER_OPTION_STS = (1 << 15),
115  LWS_SERVER_OPTION_FALLBACK_TO_RAW /* use below name */ = (1 << 20),
129  LWS_SERVER_OPTION_LIBEVENT = (1 << 21),
132  LWS_SERVER_OPTION_ONLY_RAW /* Use below name instead */ = (1 << 22),
215  /****** add new things just above ---^ ******/
216 };
217 
218 #define lws_check_opt(c, f) (((c) & (f)) == (f))
219 
220 struct lws_plat_file_ops;
221 
232  int port;
241  const char *iface;
248  const struct lws_protocols *protocols;
254  const struct lws_extension *extensions;
265  const char *ssl_cert_filepath;
291  const char *ssl_ca_filepath;
300  const char *ssl_cipher_list;
310  const char *http_proxy_address;
314  unsigned int http_proxy_port;
316  int gid;
319  int uid;
322  unsigned int options;
324  void *user;
333  int ka_time;
343 #if defined(LWS_WITH_TLS) && !defined(LWS_WITH_MBEDTLS)
344  SSL_CTX *provided_client_ssl_ctx;
349 #else /* maintain structure layout either way */
351 #endif
352 
353  unsigned short max_http_header_data;
356  unsigned short max_http_header_pool;
364  unsigned int count_threads;
366  unsigned int fd_limit_per_thread;
382  unsigned int timeout_secs;
387  const char *ecdh_curve;
390  const char *vhost_name;
394  const char * const *plugin_dirs;
403  const char *log_filepath;
406  const struct lws_http_mount *mounts;
408  const char *server_string;
411  unsigned int pt_serv_buf_size;
417  unsigned int max_http_header_data2;
426  unsigned short ws_ping_pong_interval;
463  const void *client_ssl_cert_mem;
477  const void *client_ssl_ca_mem;
480  unsigned int client_ssl_ca_mem_len;
489  const struct lws_plat_file_ops *fops;
499  const char *socks_proxy_address;
503  unsigned int socks_proxy_port;
505 #if defined(LWS_HAVE_SYS_CAPABILITY_H) && defined(LWS_HAVE_LIBCAP)
506  cap_value_t caps[4];
513  char count_caps;
516 #endif
534  unsigned int timeout_secs_ah_idle;
537  unsigned short ip_limit_ah;
545  unsigned short ip_limit_wsi;
552  uint32_t http2_settings[7];
558  const char *error_document_404;
562  const char *alpn;
583  void (*signal_cb)(void *event_lib_handle, int signum);
589  struct lws_context **pcontext;
595  void (*finalize)(struct lws_vhost *vh, void *arg);
604  unsigned int max_http_header_pool2;
628  const char *listen_accept_role;
637  const struct lws_protocols **pprotocols;
648  const void *server_ssl_cert_mem;
662  const void *server_ssl_ca_mem;
666  unsigned int server_ssl_ca_mem_len;
668  const char *username;
670  const char *groupname;
672  const char *unix_socket_perms;
680  /* Add new things just above here ---^
681  * This is part of the ABI, don't needlessly break compatibility
682  *
683  * The below is to ensure later library versions with new
684  * members added above will see 0 (default) even if the app
685  * was not built against the newer headers.
686  */
687 
688  void *_unused[4];
689 };
690 
725 LWS_VISIBLE LWS_EXTERN struct lws_context *
727 
728 
737 LWS_VISIBLE LWS_EXTERN void
738 lws_context_destroy(struct lws_context *context);
739 
740 typedef int (*lws_reload_func)(void);
741 
764 LWS_VISIBLE LWS_EXTERN void
765 lws_context_deprecate(struct lws_context *context, lws_reload_func cb);
766 
767 LWS_VISIBLE LWS_EXTERN int
768 lws_context_is_deprecated(struct lws_context *context);
769 
787 LWS_VISIBLE LWS_EXTERN int
788 lws_set_proxy(struct lws_vhost *vhost, const char *proxy);
789 
807 LWS_VISIBLE LWS_EXTERN int
808 lws_set_socks(struct lws_vhost *vhost, const char *socks);
809 
810 struct lws_vhost;
811 
821 LWS_VISIBLE LWS_EXTERN struct lws_vhost *
822 lws_create_vhost(struct lws_context *context,
823  const struct lws_context_creation_info *info);
824 
843 LWS_VISIBLE LWS_EXTERN void
844 lws_vhost_destroy(struct lws_vhost *vh);
845 
860 LWS_VISIBLE LWS_EXTERN int
862  char **config_strings, int *len);
863 
879 LWS_VISIBLE LWS_EXTERN int
880 lwsws_get_config_vhosts(struct lws_context *context,
881  struct lws_context_creation_info *info, const char *d,
882  char **config_strings, int *len);
883 
889 LWS_VISIBLE LWS_EXTERN struct lws_vhost *
890 lws_get_vhost(struct lws *wsi);
891 
897 LWS_VISIBLE LWS_EXTERN const char *
898 lws_get_vhost_name(struct lws_vhost *vhost);
899 
908 LWS_VISIBLE LWS_EXTERN struct lws_vhost *
909 lws_get_vhost_by_name(struct lws_context *context, const char *name);
910 
916 LWS_VISIBLE LWS_EXTERN int
917 lws_get_vhost_port(struct lws_vhost *vhost);
918 
924 LWS_VISIBLE LWS_EXTERN void *
925 lws_get_vhost_user(struct lws_vhost *vhost);
926 
932 LWS_VISIBLE LWS_EXTERN const char *
933 lws_get_vhost_iface(struct lws_vhost *vhost);
934 
942 LWS_VISIBLE LWS_EXTERN int
943 lws_json_dump_vhost(const struct lws_vhost *vh, char *buf, int len);
944 
955 LWS_VISIBLE LWS_EXTERN int
956 lws_json_dump_context(const struct lws_context *context, char *buf, int len,
957  int hide_vhosts);
958 
967 LWS_VISIBLE LWS_EXTERN void *
968 lws_vhost_user(struct lws_vhost *vhost);
969 
979 LWS_VISIBLE LWS_EXTERN void *
980 lws_context_user(struct lws_context *context);
981 
988 
997  const char *name;
998  const char *value;
999 };
1000 
1013 };
1014 
1022  const char *mountpoint;
1024  const char *origin;
1026  const char *def;
1028  const char *protocol;
1044  unsigned int auth_mask;
1047  unsigned int cache_reusable:1;
1048  unsigned int cache_revalidate:1;
1049  unsigned int cache_intermediaries:1;
1051  unsigned char origin_protocol;
1052  unsigned char mountpoint_len;
1057  /* Add new things just above here ---^
1058  * This is part of the ABI, don't needlessly break compatibility
1059  *
1060  * The below is to ensure later library versions with new
1061  * members added above will see 0 (default) even if the app
1062  * was not built against the newer headers.
1063  */
1064 
1065  void *_unused[2];
1066 };
1067 
LWS_VISIBLE LWS_EXTERN struct lws_vhost * lws_get_vhost(struct lws *wsi)
LWS_VISIBLE LWS_EXTERN void lws_context_deprecate(struct lws_context *context, lws_reload_func cb)
LWS_VISIBLE LWS_EXTERN int lws_json_dump_context(const struct lws_context *context, char *buf, int len, int hide_vhosts)
LWS_VISIBLE LWS_EXTERN int lwsws_get_config_vhosts(struct lws_context *context, struct lws_context_creation_info *info, const char *d, char **config_strings, int *len)
lws_context_options
Definition: lws-context-vhost.h:45
LWS_VISIBLE LWS_EXTERN const char * lws_get_vhost_name(struct lws_vhost *vhost)
LWS_VISIBLE LWS_EXTERN void * lws_get_vhost_user(struct lws_vhost *vhost)
LWS_VISIBLE LWS_EXTERN struct lws_vhost * lws_get_vhost_by_name(struct lws_context *context, const char *name)
LWS_VISIBLE LWS_EXTERN int lws_set_proxy(struct lws_vhost *vhost, const char *proxy)
LWS_VISIBLE LWS_EXTERN const char * lws_get_vhost_iface(struct lws_vhost *vhost)
LWS_VISIBLE LWS_EXTERN void lws_context_destroy(struct lws_context *context)
LWS_VISIBLE LWS_EXTERN int lws_json_dump_vhost(const struct lws_vhost *vh, char *buf, int len)
LWS_VISIBLE LWS_EXTERN int lwsws_get_config_globals(struct lws_context_creation_info *info, const char *d, char **config_strings, int *len)
LWS_VISIBLE LWS_EXTERN int lws_set_socks(struct lws_vhost *vhost, const char *socks)
LWS_VISIBLE LWS_EXTERN struct lws_context * lws_create_context(const struct lws_context_creation_info *info)
LWS_VISIBLE LWS_EXTERN int lws_get_vhost_port(struct lws_vhost *vhost)
LWS_VISIBLE LWS_EXTERN struct lws_vhost * lws_create_vhost(struct lws_context *context, const struct lws_context_creation_info *info)
LWS_VISIBLE LWS_EXTERN void lws_vhost_destroy(struct lws_vhost *vh)
LWS_VISIBLE LWS_EXTERN void * lws_vhost_user(struct lws_vhost *vhost)
LWS_VISIBLE LWS_EXTERN void * lws_context_user(struct lws_context *context)
@ LWS_SERVER_OPTION_LIBEVENT
Definition: lws-context-vhost.h:129
@ LWS_SERVER_OPTION_SSL_ECDH
Definition: lws-context-vhost.h:72
@ LWS_SERVER_OPTION_ALLOW_NON_SSL_ON_SSL_PORT
Definition: lws-context-vhost.h:53
@ LWS_SERVER_OPTION_LIBEV
Definition: lws-context-vhost.h:61
@ LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT
Definition: lws-context-vhost.h:46
@ LWS_SERVER_OPTION_HTTP_HEADERS_SECURITY_BEST_PRACTICES_ENFORCE
Definition: lws-context-vhost.h:181
@ LWS_SERVER_OPTION_DISABLE_IPV6
Definition: lws-context-vhost.h:63
@ LWS_SERVER_OPTION_REDIRECT_HTTP_TO_HTTPS
Definition: lws-context-vhost.h:77
@ LWS_SERVER_OPTION_DISABLE_OS_CA_CERTS
Definition: lws-context-vhost.h:65
@ LWS_SERVER_OPTION_ALLOW_LISTEN_SHARE
Definition: lws-context-vhost.h:146
@ LWS_SERVER_OPTION_ALLOW_HTTP_ON_HTTPS_LISTENER
Definition: lws-context-vhost.h:198
@ LWS_SERVER_OPTION_SKIP_SERVER_CANONICAL_NAME
Definition: lws-context-vhost.h:51
@ LWS_SERVER_OPTION_VHOST_UPG_STRICT_HOST_CHECK
Definition: lws-context-vhost.h:170
@ LWS_SERVER_OPTION_ADOPT_APPLY_LISTEN_ACCEPT_CONFIG
Definition: lws-context-vhost.h:133
@ LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT
Definition: lws-context-vhost.h:88
@ LWS_SERVER_OPTION_UV_NO_SIGSEGV_SIGFPE_SPIN
Definition: lws-context-vhost.h:102
@ LWS_SERVER_OPTION_UNIX_SOCK
Definition: lws-context-vhost.h:93
@ LWS_SERVER_OPTION_SKIP_PROTOCOL_INIT
Definition: lws-context-vhost.h:159
@ LWS_SERVER_OPTION_VALIDATE_UTF8
Definition: lws-context-vhost.h:70
@ LWS_SERVER_OPTION_JUST_USE_RAW_ORIGIN
Definition: lws-context-vhost.h:108
@ LWS_SERVER_OPTION_CREATE_VHOST_SSL_CTX
Definition: lws-context-vhost.h:152
@ LWS_SERVER_OPTION_PEER_CERT_NOT_REQUIRED
Definition: lws-context-vhost.h:68
@ LWS_SERVER_OPTION_H2_JUST_FIX_WINDOW_UPDATE_OVERFLOW
Definition: lws-context-vhost.h:211
@ LWS_SERVER_OPTION_STS
Definition: lws-context-vhost.h:95
@ LWS_SERVER_OPTION_IPV6_V6ONLY_VALUE
Definition: lws-context-vhost.h:100
@ LWS_SERVER_OPTION_EXPLICIT_VHOSTS
Definition: lws-context-vhost.h:90
@ LWS_SERVER_OPTION_FALLBACK_TO_APPLY_LISTEN_ACCEPT_CONFIG
Definition: lws-context-vhost.h:116
@ LWS_SERVER_OPTION_IPV6_V6ONLY_MODIFY
Definition: lws-context-vhost.h:98
@ LWS_SERVER_OPTION_IGNORE_MISSING_CERT
Definition: lws-context-vhost.h:164
@ LWS_SERVER_OPTION_FAIL_UPON_UNABLE_TO_BIND
Definition: lws-context-vhost.h:206
@ LWS_SERVER_OPTION_LIBUV
Definition: lws-context-vhost.h:75
lws_mount_protocols
Definition: lws-context-vhost.h:1005
@ LWSMPRO_CGI
Definition: lws-context-vhost.h:1009
@ LWSMPRO_HTTP
Definition: lws-context-vhost.h:1006
@ LWSMPRO_FILE
Definition: lws-context-vhost.h:1008
@ LWSMPRO_REDIR_HTTPS
Definition: lws-context-vhost.h:1011
@ LWSMPRO_CALLBACK
Definition: lws-context-vhost.h:1012
@ LWSMPRO_REDIR_HTTP
Definition: lws-context-vhost.h:1010
@ LWSMPRO_HTTPS
Definition: lws-context-vhost.h:1007
Definition: lws-context-vhost.h:231
void ** foreign_loops
Definition: lws-context-vhost.h:569
long ssl_client_options_clear
Definition: lws-context-vhost.h:612
const char * client_ssl_cert_filepath
Definition: lws-context-vhost.h:460
const char * error_document_404
Definition: lws-context-vhost.h:558
void * provided_client_ssl_ctx
Definition: lws-context-vhost.h:350
void * user
Definition: lws-context-vhost.h:324
const lws_system_ops_t * system_ops
Definition: lws-context-vhost.h:676
int bind_iface
Definition: lws-context-vhost.h:517
const char * server_string
Definition: lws-context-vhost.h:408
const struct lws_http_mount * mounts
Definition: lws-context-vhost.h:406
int simultaneous_ssl_restriction
Definition: lws-context-vhost.h:496
unsigned int client_ssl_cert_mem_len
Definition: lws-context-vhost.h:466
void(* finalize)(struct lws_vhost *vh, void *arg)
Definition: lws-context-vhost.h:595
unsigned short max_http_header_data
Definition: lws-context-vhost.h:353
int ssl_info_event_mask
Definition: lws-context-vhost.h:528
const char * client_ssl_private_key_filepath
Definition: lws-context-vhost.h:469
unsigned short ws_ping_pong_interval
Definition: lws-context-vhost.h:426
int ka_interval
Definition: lws-context-vhost.h:340
int ka_probes
Definition: lws-context-vhost.h:336
const char * ssl_cipher_list
Definition: lws-context-vhost.h:300
int port
Definition: lws-context-vhost.h:232
unsigned int fd_limit_per_thread
Definition: lws-context-vhost.h:366
const struct lws_extension * extensions
Definition: lws-context-vhost.h:254
const char * listen_accept_protocol
Definition: lws-context-vhost.h:633
const struct lws_protocols ** pprotocols
Definition: lws-context-vhost.h:637
const char * ssl_ca_filepath
Definition: lws-context-vhost.h:291
unsigned int timeout_secs_ah_idle
Definition: lws-context-vhost.h:534
struct lws_context ** pcontext
Definition: lws-context-vhost.h:589
unsigned int pt_serv_buf_size
Definition: lws-context-vhost.h:411
const char * socks_proxy_address
Definition: lws-context-vhost.h:499
unsigned int client_ssl_ca_mem_len
Definition: lws-context-vhost.h:480
const struct lws_plat_file_ops * fops
Definition: lws-context-vhost.h:489
const char * client_ssl_ca_filepath
Definition: lws-context-vhost.h:475
const char * client_ssl_cipher_list
Definition: lws-context-vhost.h:484
const struct lws_protocol_vhost_options * reject_service_keywords
Definition: lws-context-vhost.h:442
unsigned int timeout_secs
Definition: lws-context-vhost.h:382
long ssl_options_set
Definition: lws-context-vhost.h:422
unsigned int server_ssl_ca_mem_len
Definition: lws-context-vhost.h:666
const char * iface
Definition: lws-context-vhost.h:241
const char * alpn
Definition: lws-context-vhost.h:562
const char * listen_accept_role
Definition: lws-context-vhost.h:628
unsigned int http_proxy_port
Definition: lws-context-vhost.h:314
const char *const * plugin_dirs
Definition: lws-context-vhost.h:394
int keepalive_timeout
Definition: lws-context-vhost.h:400
const char * username
Definition: lws-context-vhost.h:668
const struct lws_protocol_vhost_options * headers
Definition: lws-context-vhost.h:438
const char * client_ssl_private_key_password
Definition: lws-context-vhost.h:457
const void * server_ssl_private_key_mem
Definition: lws-context-vhost.h:655
const struct lws_protocol_vhost_options * pvo
Definition: lws-context-vhost.h:397
const char * groupname
Definition: lws-context-vhost.h:670
long ssl_client_options_set
Definition: lws-context-vhost.h:610
const void * client_ssl_cert_mem
Definition: lws-context-vhost.h:463
int gid
Definition: lws-context-vhost.h:316
unsigned int options
Definition: lws-context-vhost.h:322
unsigned int server_ssl_cert_mem_len
Definition: lws-context-vhost.h:652
unsigned int max_http_header_data2
Definition: lws-context-vhost.h:417
void * external_baggage_free_on_destroy
Definition: lws-context-vhost.h:449
uint32_t http2_settings[7]
Definition: lws-context-vhost.h:552
const void * client_ssl_ca_mem
Definition: lws-context-vhost.h:477
const char * unix_socket_perms
Definition: lws-context-vhost.h:672
const char * ssl_private_key_filepath
Definition: lws-context-vhost.h:277
const struct lws_protocols * protocols
Definition: lws-context-vhost.h:248
int uid
Definition: lws-context-vhost.h:319
const void * server_ssl_ca_mem
Definition: lws-context-vhost.h:662
const void * server_ssl_cert_mem
Definition: lws-context-vhost.h:648
unsigned short ip_limit_ah
Definition: lws-context-vhost.h:537
int ka_time
Definition: lws-context-vhost.h:333
void * _unused[4]
Definition: lws-context-vhost.h:688
const char * ssl_cert_filepath
Definition: lws-context-vhost.h:265
const struct lws_token_limits * token_limits
Definition: lws-context-vhost.h:257
unsigned int server_ssl_private_key_mem_len
Definition: lws-context-vhost.h:660
const char * log_filepath
Definition: lws-context-vhost.h:403
const char * vhost_name
Definition: lws-context-vhost.h:390
const char * client_tls_1_3_plus_cipher_list
Definition: lws-context-vhost.h:622
void * finalize_arg
Definition: lws-context-vhost.h:600
const char * tls1_3_plus_cipher_list
Definition: lws-context-vhost.h:615
long ssl_options_clear
Definition: lws-context-vhost.h:424
unsigned int max_http_header_pool2
Definition: lws-context-vhost.h:604
unsigned int socks_proxy_port
Definition: lws-context-vhost.h:503
void(* signal_cb)(void *event_lib_handle, int signum)
Definition: lws-context-vhost.h:583
unsigned short ip_limit_wsi
Definition: lws-context-vhost.h:545
unsigned int count_threads
Definition: lws-context-vhost.h:364
const char * http_proxy_address
Definition: lws-context-vhost.h:310
const char * ssl_private_key_password
Definition: lws-context-vhost.h:260
unsigned short max_http_header_pool
Definition: lws-context-vhost.h:356
const char * ecdh_curve
Definition: lws-context-vhost.h:387
Definition: lws-ws-ext.h:138
Definition: lws-context-vhost.h:1019
const struct lws_http_mount * mount_next
Definition: lws-context-vhost.h:1020
const char * protocol
Definition: lws-context-vhost.h:1028
const struct lws_protocol_vhost_options * interpret
Definition: lws-context-vhost.h:1037
const char * origin
Definition: lws-context-vhost.h:1024
const char * basic_auth_login_file
Definition: lws-context-vhost.h:1054
int cache_max_age
Definition: lws-context-vhost.h:1042
const struct lws_protocol_vhost_options * extra_mimetypes
Definition: lws-context-vhost.h:1035
int cgi_timeout
Definition: lws-context-vhost.h:1040
unsigned int auth_mask
Definition: lws-context-vhost.h:1044
unsigned char origin_protocol
Definition: lws-context-vhost.h:1051
void * _unused[2]
Definition: lws-context-vhost.h:1065
unsigned int cache_reusable
Definition: lws-context-vhost.h:1047
const char * mountpoint
Definition: lws-context-vhost.h:1022
unsigned int cache_intermediaries
Definition: lws-context-vhost.h:1049
unsigned char mountpoint_len
Definition: lws-context-vhost.h:1052
unsigned int cache_revalidate
Definition: lws-context-vhost.h:1048
const struct lws_protocol_vhost_options * cgienv
Definition: lws-context-vhost.h:1031
const char * def
Definition: lws-context-vhost.h:1026
Definition: lws-vfs.h:94
Definition: lws-context-vhost.h:994
const char * value
Definition: lws-context-vhost.h:998
const struct lws_protocol_vhost_options * next
Definition: lws-context-vhost.h:995
const char * name
Definition: lws-context-vhost.h:997
const struct lws_protocol_vhost_options * options
Definition: lws-context-vhost.h:996
Definition: lws-protocols-plugins.h:43
Definition: lws-system.h:46
Definition: lws-http.h:335