version 1.1.1.2, 2014/06/15 20:20:06
|
version 1.1.1.3, 2016/11/02 10:35:00
|
Line 1
|
Line 1
|
|
#include "first.h" |
|
|
#include "base.h" |
#include "base.h" |
#include "log.h" |
#include "log.h" |
#include "buffer.h" |
#include "buffer.h" |
Line 7
|
Line 9
|
#include "inet_ntop_cache.h" |
#include "inet_ntop_cache.h" |
#include "configfile.h" |
#include "configfile.h" |
|
|
#ifdef HAVE_CONFIG_H |
|
#include "config.h" |
|
#endif |
|
|
|
#include <assert.h> |
#include <assert.h> |
#include <ctype.h> |
#include <ctype.h> |
#include <stdlib.h> |
#include <stdlib.h> |
Line 135 FREE_FUNC(mod_extforward_free) {
|
Line 133 FREE_FUNC(mod_extforward_free) {
|
for (i = 0; i < srv->config_context->used; i++) { |
for (i = 0; i < srv->config_context->used; i++) { |
plugin_config *s = p->config_storage[i]; |
plugin_config *s = p->config_storage[i]; |
|
|
if (!s) continue; | if (NULL == s) continue; |
|
|
array_free(s->forwarder); |
array_free(s->forwarder); |
array_free(s->headers); |
array_free(s->headers); |
Line 168 SETDEFAULTS_FUNC(mod_extforward_set_defaults) {
|
Line 166 SETDEFAULTS_FUNC(mod_extforward_set_defaults) {
|
p->config_storage = calloc(1, srv->config_context->used * sizeof(plugin_config *)); |
p->config_storage = calloc(1, srv->config_context->used * sizeof(plugin_config *)); |
|
|
for (i = 0; i < srv->config_context->used; i++) { |
for (i = 0; i < srv->config_context->used; i++) { |
|
data_config const* config = (data_config const*)srv->config_context->data[i]; |
plugin_config *s; |
plugin_config *s; |
|
|
s = calloc(1, sizeof(plugin_config)); |
s = calloc(1, sizeof(plugin_config)); |
Line 179 SETDEFAULTS_FUNC(mod_extforward_set_defaults) {
|
Line 178 SETDEFAULTS_FUNC(mod_extforward_set_defaults) {
|
|
|
p->config_storage[i] = s; |
p->config_storage[i] = s; |
|
|
if (0 != config_insert_values_global(srv, ((data_config *)srv->config_context->data[i])->value, cv)) { | if (0 != config_insert_values_global(srv, config->value, cv, i == 0 ? T_CONFIG_SCOPE_SERVER : T_CONFIG_SCOPE_CONNECTION)) { |
return HANDLER_ERROR; |
return HANDLER_ERROR; |
} |
} |
} |
} |
Line 236 static void put_string_into_array_len(array *ary, cons
|
Line 235 static void put_string_into_array_len(array *ary, cons
|
static array *extract_forward_array(buffer *pbuffer) |
static array *extract_forward_array(buffer *pbuffer) |
{ |
{ |
array *result = array_init(); |
array *result = array_init(); |
if (pbuffer->used > 0) { | if (!buffer_string_is_empty(pbuffer)) { |
char *base, *curr; |
char *base, *curr; |
/* state variable, 0 means not in string, 1 means in string */ |
/* state variable, 0 means not in string, 1 means in string */ |
int in_str = 0; |
int in_str = 0; |
Line 353 static void ipstr_to_sockaddr(server *srv, const char
|
Line 352 static void ipstr_to_sockaddr(server *srv, const char
|
|
|
static void clean_cond_cache(server *srv, connection *con) { |
static void clean_cond_cache(server *srv, connection *con) { |
config_cond_cache_reset_item(srv, con, COMP_HTTP_REMOTE_IP); |
config_cond_cache_reset_item(srv, con, COMP_HTTP_REMOTE_IP); |
|
config_cond_cache_reset_item(srv, con, COMP_HTTP_SCHEME); |
} |
} |
|
|
URIHANDLER_FUNC(mod_extforward_uri_handler) { |
URIHANDLER_FUNC(mod_extforward_uri_handler) { |
Line 445 URIHANDLER_FUNC(mod_extforward_uri_handler) {
|
Line 445 URIHANDLER_FUNC(mod_extforward_uri_handler) {
|
if (sock.plain.sa_family != AF_UNSPEC) { |
if (sock.plain.sa_family != AF_UNSPEC) { |
/* we found the remote address, modify current connection and save the old address */ |
/* we found the remote address, modify current connection and save the old address */ |
if (con->plugin_ctx[p->id]) { |
if (con->plugin_ctx[p->id]) { |
log_error_write(srv, __FILE__, __LINE__, "s", | if (con->conf.log_request_handling) { |
"patching an already patched connection!"); | log_error_write(srv, __FILE__, __LINE__, "s", |
| "-- mod_extforward_uri_handler already patched this connection, resetting state"); |
| } |
handler_ctx_free(con->plugin_ctx[p->id]); |
handler_ctx_free(con->plugin_ctx[p->id]); |
con->plugin_ctx[p->id] = NULL; |
con->plugin_ctx[p->id] = NULL; |
} |
} |
Line 456 URIHANDLER_FUNC(mod_extforward_uri_handler) {
|
Line 458 URIHANDLER_FUNC(mod_extforward_uri_handler) {
|
con->dst_addr = sock; |
con->dst_addr = sock; |
con->dst_addr_buf = buffer_init(); |
con->dst_addr_buf = buffer_init(); |
buffer_copy_string(con->dst_addr_buf, real_remote_addr); |
buffer_copy_string(con->dst_addr_buf, real_remote_addr); |
| |
if (con->conf.log_request_handling) { |
if (con->conf.log_request_handling) { |
log_error_write(srv, __FILE__, __LINE__, "ss", |
log_error_write(srv, __FILE__, __LINE__, "ss", |
"patching con->dst_addr_buf for the accesslog:", real_remote_addr); |
"patching con->dst_addr_buf for the accesslog:", real_remote_addr); |