[PATCH 2 of 5] Free nginx: changed server name
Maxim Dounin
mdounin at mdounin.ru
Mon Feb 19 13:46:47 UTC 2024
# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1708301526 -10800
# Mon Feb 19 03:12:06 2024 +0300
# Node ID 23f109f0faccc22772d3bb939ad8d3f23c603194
# Parent 985b0bda403cd49580dc6bf080868f04b0ff0849
Free nginx: changed server name.
diff --git a/src/core/nginx.h b/src/core/nginx.h
--- a/src/core/nginx.h
+++ b/src/core/nginx.h
@@ -11,7 +11,9 @@
#define nginx_version 1025004
#define NGINX_VERSION "1.25.4"
-#define NGINX_VER "nginx/" NGINX_VERSION
+
+#define NGINX_NAME "freenginx"
+#define NGINX_VER NGINX_NAME "/" NGINX_VERSION
#ifdef NGX_BUILD
#define NGINX_VER_BUILD NGINX_VER " (" NGX_BUILD ")"
diff --git a/src/http/v2/ngx_http_v2_filter_module.c b/src/http/v2/ngx_http_v2_filter_module.c
--- a/src/http/v2/ngx_http_v2_filter_module.c
+++ b/src/http/v2/ngx_http_v2_filter_module.c
@@ -115,12 +115,14 @@ ngx_http_v2_header_filter(ngx_http_reque
ngx_http_core_srv_conf_t *cscf;
u_char addr[NGX_SOCKADDR_STRLEN];
- static const u_char nginx[5] = "\x84\xaa\x63\x55\xe7";
#if (NGX_HTTP_GZIP)
static const u_char accept_encoding[12] =
"\x8b\x84\x84\x2d\x69\x5b\x05\x44\x3c\x86\xaa\x6f";
#endif
+ static size_t nginx_name_len = ngx_http_v2_literal_size(NGINX_NAME);
+ static u_char nginx_name[ngx_http_v2_literal_size(NGINX_VER)];
+
static size_t nginx_ver_len = ngx_http_v2_literal_size(NGINX_VER);
static u_char nginx_ver[ngx_http_v2_literal_size(NGINX_VER)];
@@ -226,7 +228,7 @@ ngx_http_v2_header_filter(ngx_http_reque
len += 1 + nginx_ver_build_len;
} else {
- len += 1 + sizeof(nginx);
+ len += 1 + nginx_name_len;
}
}
@@ -434,8 +436,9 @@ ngx_http_v2_header_filter(ngx_http_reque
NGINX_VER_BUILD);
} else {
- ngx_log_debug0(NGX_LOG_DEBUG_HTTP, fc->log, 0,
- "http2 output header: \"server: nginx\"");
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, fc->log, 0,
+ "http2 output header: \"server: %s\"",
+ NGINX_NAME);
}
*pos++ = ngx_http_v2_inc_indexed(NGX_HTTP_V2_SERVER_INDEX);
@@ -460,7 +463,13 @@ ngx_http_v2_header_filter(ngx_http_reque
pos = ngx_cpymem(pos, nginx_ver_build, nginx_ver_build_len);
} else {
- pos = ngx_cpymem(pos, nginx, sizeof(nginx));
+ if (nginx_name[0] == '\0') {
+ p = ngx_http_v2_write_value(nginx_name, (u_char *) NGINX_NAME,
+ sizeof(NGINX_NAME) - 1, tmp);
+ nginx_name_len = p - nginx_name;
+ }
+
+ pos = ngx_cpymem(pos, nginx_name, nginx_name_len);
}
}
diff --git a/src/http/v3/ngx_http_v3_filter_module.c b/src/http/v3/ngx_http_v3_filter_module.c
--- a/src/http/v3/ngx_http_v3_filter_module.c
+++ b/src/http/v3/ngx_http_v3_filter_module.c
@@ -166,7 +166,7 @@ ngx_http_v3_header_filter(ngx_http_reque
n = sizeof(NGINX_VER_BUILD) - 1;
} else {
- n = sizeof("nginx") - 1;
+ n = sizeof(NGINX_NAME) - 1;
}
len += ngx_http_v3_encode_field_lri(NULL, 0,
@@ -349,8 +349,8 @@ ngx_http_v3_header_filter(ngx_http_reque
n = sizeof(NGINX_VER_BUILD) - 1;
} else {
- p = (u_char *) "nginx";
- n = sizeof("nginx") - 1;
+ p = (u_char *) NGINX_NAME;
+ n = sizeof(NGINX_NAME) - 1;
}
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
More information about the nginx-devel
mailing list