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.
This commit is contained in:
Frederic Cambus 2020-02-18 22:29:41 +01:00 committed by Joris Vink
parent cc6ab4f05d
commit b4ebee5913
2 changed files with 17 additions and 5 deletions

View File

@ -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
@ -1291,6 +1293,14 @@ configure_http_body_disk_path(char *path)
return (KORE_RESULT_OK);
}
static int
configure_http_server_version(char *version)
{
http_server_version(version);
return (KORE_RESULT_OK);
}
static int
configure_http_hsts_enable(char *option)
{

View File

@ -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",