diff --git a/src/mod_evasive.c b/src/mod_evasive.c index 53aacb1d..26362c09 100644 --- a/src/mod_evasive.c +++ b/src/mod_evasive.c @@ -7,8 +7,6 @@ #include "plugin.h" -#include "inet_ntop_cache.h" - #include #include @@ -194,8 +192,8 @@ URIHANDLER_FUNC(mod_evasive_uri_handler) { if (conns_by_ip > p->conf.max_conns) { if (!p->conf.silent) { - log_error_write(srv, __FILE__, __LINE__, "ss", - inet_ntop_cache_get_ip(srv, &(con->dst_addr)), + log_error_write(srv, __FILE__, __LINE__, "bs", + con->dst_addr_buf, "turned away. Too many connections."); } diff --git a/src/mod_extforward.c b/src/mod_extforward.c index 144e3206..86941440 100644 --- a/src/mod_extforward.c +++ b/src/mod_extforward.c @@ -366,16 +366,8 @@ static void clean_cond_cache(server *srv, connection *con) { URIHANDLER_FUNC(mod_extforward_uri_handler) { plugin_data *p = p_d; data_string *forwarded = NULL; -#ifdef HAVE_IPV6 - char b2[INET6_ADDRSTRLEN + 1]; -#endif - const char *dst_addr_str = NULL; array *forward_array = NULL; const char *real_remote_addr = NULL; -#ifdef HAVE_IPV6 -#endif - - if (!con->request.headers) return HANDLER_GO_ON; mod_extforward_patch_connection(srv, con, p); @@ -405,21 +397,11 @@ URIHANDLER_FUNC(mod_extforward_uri_handler) { return HANDLER_GO_ON; } -#ifdef HAVE_IPV6 - dst_addr_str = inet_ntop(con->dst_addr.plain.sa_family, - con->dst_addr.plain.sa_family == AF_INET6 ? - (struct sockaddr *)&(con->dst_addr.ipv6.sin6_addr) : - (struct sockaddr *)&(con->dst_addr.ipv4.sin_addr), - b2, (sizeof b2) - 1); -#else - dst_addr_str = inet_ntoa(con->dst_addr.ipv4.sin_addr); -#endif - /* if the remote ip itself is not trusted, then do nothing */ - if (IP_UNTRUSTED == is_proxy_trusted(dst_addr_str, p)) { + if (IP_UNTRUSTED == is_proxy_trusted(con->dst_addr_buf->ptr, p)) { if (con->conf.log_request_handling) { - log_error_write(srv, __FILE__, __LINE__, "sss", - "remote address", dst_addr_str, "is NOT a trusted proxy, skipping"); + log_error_write(srv, __FILE__, __LINE__, "sbs", + "remote address", con->dst_addr_buf, "is NOT a trusted proxy, skipping"); } return HANDLER_GO_ON; diff --git a/src/mod_proxy.c b/src/mod_proxy.c index 11ef57e4..a74d3abc 100644 --- a/src/mod_proxy.c +++ b/src/mod_proxy.c @@ -13,7 +13,6 @@ #include "plugin.h" -#include "inet_ntop_cache.h" #include "crc32.h" #include @@ -656,7 +655,7 @@ static int proxy_create_env(server *srv, handler_ctx *hctx) { buffer_append_string_len(b, CONST_STR_LEN("\r\n")); } - proxy_append_header(con, "X-Forwarded-For", (char *)inet_ntop_cache_get_ip(srv, &(con->dst_addr))); + proxy_append_header(con, "X-Forwarded-For", con->dst_addr_buf->ptr); /* http_host is NOT is just a pointer to a buffer * which is NULL if it is not set */ if (!buffer_string_is_empty(con->request.http_host)) { diff --git a/src/mod_status.c b/src/mod_status.c index 38e5bdd9..0239fcd6 100644 --- a/src/mod_status.c +++ b/src/mod_status.c @@ -8,8 +8,6 @@ #include "plugin.h" -#include "inet_ntop_cache.h" - #include #include @@ -516,7 +514,7 @@ static handler_t mod_status_handle_server_status_html(server *srv, connection *c buffer_append_string_len(b, CONST_STR_LEN("")); - buffer_append_string(b, inet_ntop_cache_get_ip(srv, &(c->dst_addr))); + buffer_append_string_buffer(b, c->dst_addr_buf); buffer_append_string_len(b, CONST_STR_LEN("")); diff --git a/src/mod_trigger_b4_dl.c b/src/mod_trigger_b4_dl.c index 8ccb0906..5d5a23d1 100644 --- a/src/mod_trigger_b4_dl.c +++ b/src/mod_trigger_b4_dl.c @@ -6,7 +6,6 @@ #include "plugin.h" #include "response.h" -#include "inet_ntop_cache.h" #include #include @@ -361,7 +360,7 @@ URIHANDLER_FUNC(mod_trigger_b4_dl_uri_handler) { /* memcache can't handle spaces */ } else { - remote_ip = inet_ntop_cache_get_ip(srv, &(con->dst_addr)); + remote_ip = con->dst_addr_buf->ptr; } if (p->conf.debug) {