kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit b4ebee59135da4dc0976f4111ebbb7a6ae32b901
parent cc6ab4f05d914b76321d34d3bc4b2bc06f32396a
Author: Frederic Cambus <fred@statdns.com>
Date:   Tue, 18 Feb 2020 22:29:41 +0100

Add the http_server_version configuration option.

This allows setting a custom server header from the config file, for
example to mask the version number.

Diffstat:
src/config.c | 10++++++++++
src/http.c | 12+++++++-----
2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/src/config.c b/src/config.c @@ -128,6 +128,7 @@ static int configure_http_request_ms(char *); static int configure_http_request_limit(char *); static int configure_http_body_disk_offload(char *); static int configure_http_body_disk_path(char *); +static int configure_http_server_version(char *); static int configure_validator(char *); static int configure_params(char *); static int configure_validate(char *); @@ -254,6 +255,7 @@ static struct { { "http_request_limit", configure_http_request_limit }, { "http_body_disk_offload", configure_http_body_disk_offload }, { "http_body_disk_path", configure_http_body_disk_path }, + { "http_server_version", configure_http_server_version }, { "websocket_maxframe", configure_websocket_maxframe }, { "websocket_timeout", configure_websocket_timeout }, #endif @@ -1292,6 +1294,14 @@ configure_http_body_disk_path(char *path) } static int +configure_http_server_version(char *version) +{ + http_server_version(version); + + return (KORE_RESULT_OK); +} + +static int configure_http_hsts_enable(char *option) { int err; diff --git a/src/http.c b/src/http.c @@ -185,12 +185,14 @@ http_init(void) header_buf = kore_buf_alloc(HTTP_HEADER_BUFSIZE); ckhdr_buf = kore_buf_alloc(HTTP_COOKIE_BUFSIZE); - l = snprintf(http_version, sizeof(http_version), - "server: kore (%s)\r\n", kore_version); - if (l == -1 || (size_t)l >= sizeof(http_version)) - fatal("http_init(): http_version buffer too small"); + if (!http_version_len) { + l = snprintf(http_version, sizeof(http_version), + "server: kore (%s)\r\n", kore_version); + if (l == -1 || (size_t)l >= sizeof(http_version)) + fatal("http_init(): http_version buffer too small"); - http_version_len = l; + http_version_len = l; + } prealloc = MIN((worker_max_connections / 10), 1000); kore_pool_init(&http_request_pool, "http_request_pool",