@@ -36,6 +36,7 @@ static const char *redirectionio_set_scheme(cmd_parms *cmd, void *cfg, const cha
3636static const char * redirectionio_set_show_rule_ids (cmd_parms * cmd , void * cfg , const char * arg );
3737static const char * redirectionio_set_server (cmd_parms * cmd , void * dc , int argc , char * const argv []);
3838static const char * redirectionio_set_header (cmd_parms * cmd , void * cfg , const char * arg1 , const char * arg2 );
39+ static const char * redirectionio_set_trusted_proxies (cmd_parms * cmd , void * cfg , const char * arg );
3940static void redirectionio_apache_log_callback (const char * log_str , const void * data , short level );
4041static apr_status_t redirectionio_atoi (const char * line , apr_size_t len );
4142
@@ -47,6 +48,7 @@ static const command_rec redirectionio_directives[] = {
4748 AP_INIT_TAKE1 ("redirectionioScheme" , redirectionio_set_scheme , NULL , OR_ALL , "Force scheme to use when matching request" ),
4849 AP_INIT_TAKE1 ("redirectionioRuleIdsHeader" , redirectionio_set_show_rule_ids , NULL , OR_ALL , "Show rule ids used on response header" ),
4950 AP_INIT_TAKE2 ("redirectionioSetHeader" , redirectionio_set_header , NULL , OR_ALL , "Add header to match in redirectionio request" ),
51+ AP_INIT_TAKE1 ("redirectionioTrustedProxies" , redirectionio_set_trusted_proxies , NULL , OR_ALL , "Trusted proxies to filter client ip" ),
5052 { NULL }
5153};
5254
@@ -509,6 +511,7 @@ static void *create_redirectionio_dir_conf(apr_pool_t *pool, char *context) {
509511 config -> pool = pool ;
510512 config -> show_rule_ids = -1 ;
511513 config -> headers_set = NULL ;
514+ config -> trusted_proxies = NULL ;
512515 }
513516
514517 return config ;
@@ -578,6 +581,12 @@ static void *merge_redirectionio_dir_conf(apr_pool_t *pool, void *parent, void *
578581 conf -> server .timeout = conf_current -> server .timeout ;
579582 }
580583
584+ if (conf_current -> trusted_proxies == NULL ) {
585+ conf -> trusted_proxies = conf_parent -> trusted_proxies ;
586+ } else {
587+ conf -> trusted_proxies = conf_current -> trusted_proxies ;
588+ }
589+
581590 conf -> pool = pool ;
582591 conf -> connection_pool = NULL ;
583592
@@ -829,6 +838,16 @@ static const char *redirectionio_set_header(cmd_parms *cmd, void *cfg, const cha
829838 return NULL ;
830839}
831840
841+ static const char * redirectionio_set_trusted_proxies (cmd_parms * cmd , void * cfg , const char * arg ) {
842+ redirectionio_config * conf = (redirectionio_config * )cfg ;
843+
844+ if (conf ) {
845+ conf -> trusted_proxies = (struct REDIRECTIONIO_TrustedProxies * ) redirectionio_trusted_proxies_create (arg );
846+ }
847+
848+ return NULL ;
849+ }
850+
832851static void redirectionio_apache_log_callback (const char * log_str , const void * data , short level ) {
833852 if (level <= 1 ) {
834853 ap_log_rerror (APLOG_MARK , APLOG_ERR , 0 , (request_rec * )data , "mod_redirectionio api error: %s" , log_str );
0 commit comments