GNU libmicrohttpd 0.9.77
|
boring functions to manipulate daemon options More...
#include "internal.h"
Go to the source code of this file.
Functions | |
void | MHD_daemon_set_logger (struct MHD_Daemon *daemon, MHD_LoggingCallback logger, void *logger_cls) |
void | MHD_daemon_suppress_date_no_clock (struct MHD_Daemon *daemon) |
void | MHD_daemon_disable_itc (struct MHD_Daemon *daemon) |
void | MHD_daemon_enable_turbo (struct MHD_Daemon *daemon) |
void | MHD_daemon_disallow_suspend_resume (struct MHD_Daemon *daemon) |
void | MHD_daemon_disallow_upgrade (struct MHD_Daemon *daemon) |
enum MHD_Bool | MHD_daemon_tcp_fastopen (struct MHD_Daemon *daemon, enum MHD_FastOpenMethod fom, unsigned int queue_length) |
void | MHD_daemon_bind_port (struct MHD_Daemon *daemon, enum MHD_AddressFamily af, uint16_t port) |
void | MHD_daemon_bind_socket_address (struct MHD_Daemon *daemon, const struct sockaddr *sa, size_t sa_len) |
void | MHD_daemon_listen_backlog (struct MHD_Daemon *daemon, int listen_backlog) |
void | MHD_daemon_listen_allow_address_reuse (struct MHD_Daemon *daemon) |
_MHD_EXTERN void | MHD_daemon_enable_shoutcast (struct MHD_Daemon *daemon) |
void | MHD_daemon_listen_socket (struct MHD_Daemon *daemon, MHD_socket listen_socket) |
enum MHD_Bool | MHD_daemon_event_loop (struct MHD_Daemon *daemon, enum MHD_EventLoopSyscall els) |
void | MHD_daemon_protocol_strict_level (struct MHD_Daemon *daemon, enum MHD_ProtocolStrictLevel sl) |
enum MHD_StatusCode | MHD_daemon_set_tls_backend (struct MHD_Daemon *daemon, const char *tls_backend, const char *ciphers) |
enum MHD_StatusCode | MHD_daemon_tls_key_and_cert_from_memory (struct MHD_Daemon *daemon, const char *mem_key, const char *mem_cert, const char *pass) |
enum MHD_StatusCode | MHD_daemon_tls_mem_dhparams (struct MHD_Daemon *daemon, const char *dh) |
enum MHD_StatusCode | MHD_daemon_tls_mem_trust (struct MHD_Daemon *daemon, const char *mem_trust) |
enum MHD_StatusCode | MHD_daemon_gnutls_credentials (struct MHD_Daemon *daemon, int gnutls_credentials) |
enum MHD_StatusCode | MHD_daemon_gnutls_key_and_cert_from_callback (struct MHD_Daemon *daemon, void *cb) |
void | MHD_daemon_threading_mode (struct MHD_Daemon *daemon, enum MHD_ThreadingMode tm) |
void | MHD_daemon_accept_policy (struct MHD_Daemon *daemon, MHD_AcceptPolicyCallback apc, void *apc_cls) |
void | MHD_daemon_set_early_uri_logger (struct MHD_Daemon *daemon, MHD_EarlyUriLogCallback cb, void *cb_cls) |
void | MHD_daemon_set_notify_connection (struct MHD_Daemon *daemon, MHD_NotifyConnectionCallback ncc, void *ncc_cls) |
void | MHD_daemon_connection_memory_limit (struct MHD_Daemon *daemon, size_t memory_limit_b, size_t memory_increment_b) |
void | MHD_daemon_thread_stack_size (struct MHD_Daemon *daemon, size_t stack_limit_b) |
void | MHD_daemon_connection_limits (struct MHD_Daemon *daemon, unsigned int global_connection_limit, unsigned int ip_connection_limit) |
void | MHD_daemon_connection_default_timeout (struct MHD_Daemon *daemon, unsigned int timeout_s) |
void | MHD_daemon_unescape_cb (struct MHD_Daemon *daemon, MHD_UnescapeCallback unescape_cb, void *unescape_cb_cls) |
void | MHD_daemon_digest_auth_random (struct MHD_Daemon *daemon, size_t buf_size, const void *buf) |
enum MHD_StatusCode | MHD_daemon_digest_auth_nc_length (struct MHD_Daemon *daemon, size_t nc_length) |
boring functions to manipulate daemon options
Definition in file daemon_options.c.
void MHD_daemon_accept_policy | ( | struct MHD_Daemon * | daemon, |
MHD_AcceptPolicyCallback | apc, | ||
void * | apc_cls | ||
) |
Set a policy callback that accepts/rejects connections based on the client's IP address. This function will be called before a connection object is created.
daemon | daemon to set policy for |
apc | function to call to check the policy |
apc_cls | closure for apc |
Definition at line 560 of file daemon_options.c.
References MHD_Daemon::accept_policy_cb, and MHD_Daemon::accept_policy_cb_cls.
void MHD_daemon_bind_port | ( | struct MHD_Daemon * | daemon, |
enum MHD_AddressFamily | af, | ||
uint16_t | port | ||
) |
Bind to the given TCP port and address family.
Ineffective in conjunction with MHD_daemon_listen_socket(). Ineffective in conjunction with #MHD_daemon_bind_sa().
If neither this option nor the other two mentioned above is specified, MHD will simply not listen on any socket!
daemon | which instance to configure the TCP port for |
af | address family to use |
port | port to use, 0 to bind to a random (free) port |
Definition at line 187 of file daemon_options.c.
References MHD_Daemon::listen_af, and MHD_Daemon::listen_port.
void MHD_daemon_bind_socket_address | ( | struct MHD_Daemon * | daemon, |
const struct sockaddr * | sa, | ||
size_t | sa_len | ||
) |
Bind to the given socket address. Ineffective in conjunction with MHD_daemon_listen_socket().
daemon | which instance to configure the binding address for |
sa | address to bind to; can be IPv4 (AF_INET), IPv6 (AF_INET6) or even a UNIX domain socket (AF_UNIX) |
sa_len | number of bytes in sa |
Definition at line 206 of file daemon_options.c.
References MHD_Daemon::listen_sa, and MHD_Daemon::listen_sa_len.
void MHD_daemon_connection_default_timeout | ( | struct MHD_Daemon * | daemon, |
unsigned int | timeout_s | ||
) |
After how many seconds of inactivity should a connection automatically be timed out? Use zero for no timeout, which is also the (unsafe!) default.
daemon | daemon to configure |
timeout_s | number of seconds of timeout to use |
Definition at line 679 of file daemon_options.c.
References MHD_Daemon::connection_default_timeout.
void MHD_daemon_connection_limits | ( | struct MHD_Daemon * | daemon, |
unsigned int | global_connection_limit, | ||
unsigned int | ip_connection_limit | ||
) |
Set maximum number of concurrent connections to accept. If not given, MHD will not enforce any limits (modulo running into OS limits). Values of 0 mean no limit.
daemon | daemon to configure |
global_connection_limit | maximum number of (concurrent) connections |
ip_connection_limit | limit on the number of (concurrent) connections made to the server from the same IP address. Can be used to prevent one IP from taking over all of the allowed connections. If the same IP tries to establish more than the specified number of connections, they will be immediately rejected. |
Definition at line 661 of file daemon_options.c.
References MHD_Daemon::global_connection_limit, and MHD_Daemon::ip_connection_limit.
void MHD_daemon_connection_memory_limit | ( | struct MHD_Daemon * | daemon, |
size_t | memory_limit_b, | ||
size_t | memory_increment_b | ||
) |
Maximum memory size per connection. Default is 32 kb (MHD_POOL_SIZE_DEFAULT). Values above 128k are unlikely to result in much benefit, as half of the memory will be typically used for IO, and TCP buffers are unlikely to support window sizes above 64k on most systems.
daemon | daemon to configure |
memory_limit_b | connection memory limit to use in bytes |
memory_increment_b | increment to use when growing the read buffer, must be smaller than memory_limit_b |
Definition at line 618 of file daemon_options.c.
References MHD_Daemon::connection_memory_increment_b, MHD_Daemon::connection_memory_limit_b, and MHD_PANIC.
enum MHD_StatusCode MHD_daemon_digest_auth_nc_length | ( | struct MHD_Daemon * | daemon, |
size_t | nc_length | ||
) |
Length of the internal array holding the map of the nonce and the nonce counter.
daemon | daemon to configure |
nc_length | desired array length |
Definition at line 741 of file daemon_options.c.
References _, MHD_strerror_, and NULL.
void MHD_daemon_digest_auth_random | ( | struct MHD_Daemon * | daemon, |
size_t | buf_size, | ||
const void * | buf | ||
) |
Set random values to be used by the Digest Auth module. Note that the application must ensure that buf remains allocated and unmodified while the daemon is running.
daemon | daemon to configure |
buf_size | number of bytes in buf |
buf | entropy buffer |
Definition at line 717 of file daemon_options.c.
References MHD_PANIC.
void MHD_daemon_disable_itc | ( | struct MHD_Daemon * | daemon | ) |
Disable use of inter-thread communication channel. MHD_daemon_disable_itc() can be used with #MHD_daemon_thread_internal() to perform some additional optimizations (in particular, not creating a pipe for IPC signalling). If it is used, certain functions like MHD_daemon_quiesce() or #MHD_connection_add() or MHD_action_suspend() cannot be used anymore. MHD_daemon_disable_itc() is not beneficial on platforms where select()/poll()/other signal shutdown() of a listen socket.
You should only use this function if you are sure you do satisfy all of its requirements and need a generally minor boost in performance.
daemon | which instance to disable itc for |
Definition at line 79 of file daemon_options.c.
References MHD_Daemon::disable_itc.
void MHD_daemon_disallow_suspend_resume | ( | struct MHD_Daemon * | daemon | ) |
Disable MHD_action_suspend() functionality.
You should only use this function if you are sure you do satisfy all of its requirements and need a generally minor boost in performance.
daemon | which instance to disable suspend for |
Definition at line 110 of file daemon_options.c.
References MHD_Daemon::disallow_suspend_resume.
void MHD_daemon_disallow_upgrade | ( | struct MHD_Daemon * | daemon | ) |
You need to set this option if you want to disable use of HTTP "Upgrade". "Upgrade" may require usage of additional internal resources, which we can avoid providing if they will not be used.
You should only use this function if you are sure you do satisfy all of its requirements and need a generally minor boost in performance.
daemon | which instance to enable suspend/resume for |
Definition at line 128 of file daemon_options.c.
References MHD_Daemon::disallow_upgrade.
_MHD_EXTERN void MHD_daemon_enable_shoutcast | ( | struct MHD_Daemon * | daemon | ) |
Use SHOUTcast. This will cause the response to begin with the SHOUTcast "ICY" line instead of "HTTP".
daemon | daemon to set SHOUTcast option for |
Definition at line 256 of file daemon_options.c.
References MHD_Daemon::enable_shoutcast.
void MHD_daemon_enable_turbo | ( | struct MHD_Daemon * | daemon | ) |
Enable turbo
. Disables certain calls to shutdown()
, enables aggressive non-blocking optimistic reads and other potentially unsafe optimizations. Most effects only happen with #MHD_ELS_EPOLL.
daemon | which instance to enable turbo for |
Definition at line 94 of file daemon_options.c.
References MHD_Daemon::enable_turbo.
enum MHD_Bool MHD_daemon_event_loop | ( | struct MHD_Daemon * | daemon, |
enum MHD_EventLoopSyscall | els | ||
) |
Force use of a particular event loop system call.
daemon | daemon to set event loop style for |
els | event loop syscall to use |
Definition at line 292 of file daemon_options.c.
References MHD_Daemon::event_loop_syscall, MHD_NO, and MHD_YES.
enum MHD_StatusCode MHD_daemon_gnutls_credentials | ( | struct MHD_Daemon * | daemon, |
int | gnutls_credentials | ||
) |
Configure daemon credentials type for GnuTLS.
gnutls_credentials | must be a value of type gnutls_credentials_type_t |
Definition at line 487 of file daemon_options.c.
References NULL.
enum MHD_StatusCode MHD_daemon_gnutls_key_and_cert_from_callback | ( | struct MHD_Daemon * | daemon, |
void * | cb | ||
) |
Provide TLS key and certificate data via callback.
Use a callback to determine which X.509 certificate should be used for a given HTTPS connection. This option provides an alternative to MHD_daemon_tls_key_and_cert_from_memory(). You must use this version if multiple domains are to be hosted at the same IP address using TLS's Server Name Indication (SNI) extension. In this case, the callback is expected to select the correct certificate based on the SNI information provided. The callback is expected to access the SNI data using gnutls_server_name_get()
. Using this option requires GnuTLS 3.0 or higher.
daemon | daemon to configure callback for |
cb | must be of type gnutls_certificate_retrieve_function2 * . |
Definition at line 520 of file daemon_options.c.
References NULL.
void MHD_daemon_listen_allow_address_reuse | ( | struct MHD_Daemon * | daemon | ) |
If present true, allow reusing address:port socket (by using SO_REUSEPORT on most platform, or platform-specific ways). If present and set to false, disallow reusing address:port socket (does nothing on most platform, but uses SO_EXCLUSIVEADDRUSE on Windows). Ineffective in conjunction with MHD_daemon_listen_socket().
daemon | daemon to configure address reuse for |
Definition at line 243 of file daemon_options.c.
References MHD_Daemon::allow_address_reuse.
void MHD_daemon_listen_backlog | ( | struct MHD_Daemon * | daemon, |
int | listen_backlog | ||
) |
Use the given backlog for the listen() call. Ineffective in conjunction with MHD_daemon_listen_socket().
daemon | which instance to configure the backlog for |
listen_backlog | backlog to use |
Definition at line 225 of file daemon_options.c.
References MHD_Daemon::listen_backlog.
void MHD_daemon_listen_socket | ( | struct MHD_Daemon * | daemon, |
MHD_socket | listen_socket | ||
) |
Accept connections from the given socket. Socket must be a TCP or UNIX domain (stream) socket.
Unless -1 is given, this disables other listen options, including #MHD_daemon_bind_sa(), MHD_daemon_bind_port(), #MHD_daemon_listen_queue() and MHD_daemon_listen_allow_address_reuse().
daemon | daemon to set listen socket for |
listen_socket | listen socket to use, MHD_INVALID_SOCKET value will cause this call to be ignored (other binding options may still be effective) |
Definition at line 277 of file daemon_options.c.
References MHD_Daemon::listen_socket.
void MHD_daemon_protocol_strict_level | ( | struct MHD_Daemon * | daemon, |
enum MHD_ProtocolStrictLevel | sl | ||
) |
Set how strictly MHD will enforce the HTTP protocol.
daemon | daemon to configure strictness for |
sl | how strict should we be |
Definition at line 328 of file daemon_options.c.
References MHD_Daemon::protocol_strict_level.
void MHD_daemon_set_early_uri_logger | ( | struct MHD_Daemon * | daemon, |
MHD_EarlyUriLogCallback | cb, | ||
void * | cb_cls | ||
) |
Register a callback to be called first for every request (before any parsing of the header). Makes it easy to log the full URL.
daemon | daemon for which to set the logger |
cb | function to call |
cb_cls | closure for cb |
Definition at line 579 of file daemon_options.c.
References MHD_Daemon::early_uri_logger_cb, and MHD_Daemon::early_uri_logger_cb_cls.
void MHD_daemon_set_logger | ( | struct MHD_Daemon * | daemon, |
MHD_LoggingCallback | logger, | ||
void * | logger_cls | ||
) |
Set logging method. Specify NULL to disable logging entirely. By default (if this option is not given), we log error messages to stderr.
daemon | which instance to setup logging for |
logger | function to invoke |
logger_cls | closure for logger |
Definition at line 40 of file daemon_options.c.
References MHD_Daemon::logger, and MHD_Daemon::logger_cls.
void MHD_daemon_set_notify_connection | ( | struct MHD_Daemon * | daemon, |
MHD_NotifyConnectionCallback | ncc, | ||
void * | ncc_cls | ||
) |
Register a function that should be called whenever a connection is started or closed.
daemon | daemon to set callback for |
ncc | function to call to check the policy |
ncc_cls | closure for apc |
Definition at line 597 of file daemon_options.c.
References MHD_Daemon::notify_connection_cb, and MHD_Daemon::notify_connection_cb_cls.
enum MHD_StatusCode MHD_daemon_set_tls_backend | ( | struct MHD_Daemon * | daemon, |
const char * | tls_backend, | ||
const char * | ciphers | ||
) |
Enable and configure TLS.
daemon | which instance should be configured |
tls_backend | which TLS backend should be used, currently only "gnutls" is supported. You can also specify NULL for best-available (which is the default). |
ciphers | which ciphers should be used by TLS, default is "NORMAL" |
Definition at line 351 of file daemon_options.c.
References MHD_TLS_ABI_VERSION_STR, and NULL.
void MHD_daemon_suppress_date_no_clock | ( | struct MHD_Daemon * | daemon | ) |
Suppress use of "Date" header as this system has no RTC.
daemon | which instance to disable clock for. |
Definition at line 55 of file daemon_options.c.
References MHD_Daemon::suppress_date.
enum MHD_Bool MHD_daemon_tcp_fastopen | ( | struct MHD_Daemon * | daemon, |
enum MHD_FastOpenMethod | fom, | ||
unsigned int | queue_length | ||
) |
Configure TCP_FASTOPEN option, including setting a custom queue_length.
Note that having a larger queue size can cause resource exhaustion attack as the TCP stack has to now allocate resources for the SYN packet along with its DATA.
daemon | which instance to configure TCP_FASTOPEN for |
fom | under which conditions should we use TCP_FASTOPEN? |
queue_length | queue length to use, default is 50 if this option is never given. |
Definition at line 150 of file daemon_options.c.
References MHD_Daemon::fast_open_method, MHD_Daemon::fo_queue_length, MHD_NO, and MHD_YES.
void MHD_daemon_thread_stack_size | ( | struct MHD_Daemon * | daemon, |
size_t | stack_limit_b | ||
) |
Desired size of the stack for threads created by MHD. Use 0 for system default. Only useful if the selected threading mode is not #MHD_TM_EXTERNAL_EVENT_LOOP.
daemon | daemon to configure |
stack_limit_b | stack size to use in bytes |
Definition at line 638 of file daemon_options.c.
References MHD_Daemon::thread_stack_limit_b.
void MHD_daemon_threading_mode | ( | struct MHD_Daemon * | daemon, |
enum MHD_ThreadingMode | tm | ||
) |
Specify threading mode to use.
daemon | daemon to configure |
tm | mode to use (positive values indicate the number of worker threads to be used) |
Definition at line 543 of file daemon_options.c.
References MHD_Daemon::threading_mode.
enum MHD_StatusCode MHD_daemon_tls_key_and_cert_from_memory | ( | struct MHD_Daemon * | daemon, |
const char * | mem_key, | ||
const char * | mem_cert, | ||
const char * | pass | ||
) |
Provide TLS key and certificate data in-memory.
daemon | which instance should be configured |
mem_key | private key (key.pem) to be used by the HTTPS daemon. Must be the actual data in-memory, not a filename. |
mem_cert | certificate (cert.pem) to be used by the HTTPS daemon. Must be the actual data in-memory, not a filename. |
pass | passphrase phrase to decrypt 'key.pem', NULL if |
mem_key | is in cleartext already |
Definition at line 407 of file daemon_options.c.
References MHD_TLS_Plugin::cls, MHD_TLS_Plugin::init_kcp, and NULL.
enum MHD_StatusCode MHD_daemon_tls_mem_dhparams | ( | struct MHD_Daemon * | daemon, |
const char * | dh | ||
) |
Configure DH parameters (dh.pem) to use for the TLS key exchange.
daemon | daemon to configure tls for |
dh | parameters to use |
Definition at line 437 of file daemon_options.c.
References MHD_TLS_Plugin::cls, MHD_TLS_Plugin::init_dhparams, and NULL.
enum MHD_StatusCode MHD_daemon_tls_mem_trust | ( | struct MHD_Daemon * | daemon, |
const char * | mem_trust | ||
) |
Memory pointer for the certificate (ca.pem) to be used by the HTTPS daemon for client authentication.
daemon | daemon to configure tls for |
mem_trust | memory pointer to the certificate |
Definition at line 463 of file daemon_options.c.
References MHD_TLS_Plugin::cls, MHD_TLS_Plugin::init_mem_trust, and NULL.
void MHD_daemon_unescape_cb | ( | struct MHD_Daemon * | daemon, |
MHD_UnescapeCallback | unescape_cb, | ||
void * | unescape_cb_cls | ||
) |
Specify a function that should be called for unescaping escape sequences in URIs and URI arguments. Note that this function will NOT be used by the struct MHD_PostProcessor
. If this option is not specified, the default method will be used which decodes escape sequences of the form "%HH".
daemon | daemon to configure |
unescape_cb | function to use, NULL for default |
unescape_cb_cls | closure for unescape_cb |
Definition at line 698 of file daemon_options.c.
References MHD_Daemon::unescape_cb, and MHD_Daemon::unescape_cb_cls.