Created
February 21, 2014 12:47
-
-
Save dannysheehan/ddca8cedb6e0851d432f to your computer and use it in GitHub Desktop.
Add REMOTE_HOST functionality to NGINX mod-security - ngx_http_modsecurity.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static inline u_char *get_rdns_hostname(ngx_http_request_t *r); | |
//ctx->connection->remote_host = NULL; | |
ctx->connection->remote_host = (char *)get_rdns_hostname(r); | |
static inline u_char * | |
get_rdns_hostname(ngx_http_request_t *r){ | |
ngx_str_t variable_name = ngx_string("rdns_hostname"); | |
u_char *dst; | |
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
"ModSecurity: get_rdns_hostname"); | |
ngx_int_t hash = ngx_hash_key(variable_name.data, variable_name.len); | |
ngx_http_variable_value_t *rdns_hostname_var = | |
ngx_http_get_variable( r, &variable_name, hash); | |
if( rdns_hostname_var && | |
!rdns_hostname_var->not_found && | |
rdns_hostname_var->valid){ | |
dst = ngx_pnalloc(r->pool, rdns_hostname_var->len + 1); | |
if (dst == NULL) { | |
return NULL; | |
} | |
ngx_memcpy(dst, rdns_hostname_var->data, rdns_hostname_var->len); | |
dst[rdns_hostname_var->len] = '\0'; | |
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
"ModSecurity: rdns_hostname: \"%s\"", | |
dst); | |
return dst; | |
} | |
return NULL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment