54 lines
1.6 KiB
Python
54 lines
1.6 KiB
Python
import sys
|
|
|
|
src = 'angie-Angie-1.11.8/src/http/ngx_http_header_filter_module.c'
|
|
with open(src) as f:
|
|
content = f.read()
|
|
|
|
defs = 'static u_char ngx_http_server_string[] = "Server: Angie" CRLF;\n'
|
|
defs += 'static u_char ngx_http_server_full_string[] = "Server: " ANGIE_VER CRLF;\n'
|
|
defs += 'static u_char ngx_http_server_build_string[] = "Server: " ANGIE_VER_BUILD CRLF;\n\n'
|
|
|
|
assert defs in content, 'defs not found'
|
|
content = content.replace(defs, '')
|
|
|
|
block1 = ''' if (r->headers_out.server == NULL) {
|
|
if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_ON) {
|
|
len += sizeof(ngx_http_server_full_string) - 1;
|
|
|
|
} else if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_BUILD) {
|
|
len += sizeof(ngx_http_server_build_string) - 1;
|
|
|
|
} else {
|
|
len += sizeof(ngx_http_server_string) - 1;
|
|
}
|
|
}
|
|
|
|
'''
|
|
assert block1 in content, 'block1 not found'
|
|
content = content.replace(block1, '')
|
|
|
|
block2 = ''' if (r->headers_out.server == NULL) {
|
|
if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_ON) {
|
|
p = ngx_http_server_full_string;
|
|
len = sizeof(ngx_http_server_full_string) - 1;
|
|
|
|
} else if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_BUILD) {
|
|
p = ngx_http_server_build_string;
|
|
len = sizeof(ngx_http_server_build_string) - 1;
|
|
|
|
} else {
|
|
p = ngx_http_server_string;
|
|
len = sizeof(ngx_http_server_string) - 1;
|
|
}
|
|
|
|
b->last = ngx_cpymem(b->last, p, len);
|
|
}
|
|
|
|
'''
|
|
assert block2 in content, 'block2 not found'
|
|
content = content.replace(block2, '')
|
|
|
|
with open(src, 'w') as f:
|
|
f.write(content)
|
|
print('ALL_REMOVED')
|