1- #include "httpd.h"
2- #include "http_config.h"
3- #include "http_log.h"
4- #include "http_protocol.h"
5- #include "http_request.h"
6- #include "ap_config.h"
7- #include "apr_network_io.h"
8- #include "apr_strings.h"
9- #include "apr_uri.h"
101#include "mod_redirectionio.h"
112#include "redirectionio_protocol.h"
123
@@ -41,6 +32,8 @@ static apr_status_t redirectionio_child_exit(void *resource);
4132static const char * redirectionio_set_enable (cmd_parms * cmd , void * cfg , const char * arg );
4233static const char * redirectionio_set_project_key (cmd_parms * cmd , void * cfg , const char * arg );
4334static const char * redirectionio_set_logs_enable (cmd_parms * cmd , void * cfg , const char * arg );
35+ static const char * redirectionio_set_scheme (cmd_parms * cmd , void * cfg , const char * arg );
36+ static const char * redirectionio_set_show_rule_ids (cmd_parms * cmd , void * cfg , const char * arg );
4437static const char * redirectionio_set_pass (cmd_parms * cmd , void * cfg , const char * arg );
4538static void redirectionio_apache_log_callback (const char * log_str , const void * data , short level );
4639
@@ -49,6 +42,8 @@ static const command_rec redirectionio_directives[] = {
4942 AP_INIT_TAKE1 ("redirectionioPass" , redirectionio_set_pass , NULL , OR_ALL , "Agent server location" ),
5043 AP_INIT_TAKE1 ("redirectionioProjectKey" , redirectionio_set_project_key , NULL , OR_ALL , "RedirectionIO project key" ),
5144 AP_INIT_TAKE1 ("redirectionioLogs" , redirectionio_set_logs_enable , NULL , OR_ALL , "Enable or disable logging for redirectionio" ),
45+ AP_INIT_TAKE1 ("redirectionioScheme" , redirectionio_set_scheme , NULL , OR_ALL , "Force scheme to use when matching request" ),
46+ AP_INIT_TAKE1 ("redirectionioRuleIdsHeader" , redirectionio_set_show_rule_ids , NULL , OR_ALL , "Show rule ids used on response header" ),
5247 { NULL }
5348};
5449
@@ -509,11 +504,13 @@ static void *create_redirectionio_dir_conf(apr_pool_t *pool, char *context) {
509504 config -> enable = -1 ;
510505 config -> enable_logs = -1 ;
511506 config -> project_key = NULL ;
507+ config -> scheme = NULL ;
512508 config -> protocol = TCP ;
513509 config -> port = 10301 ;
514510 config -> server = "127.0.0.1" ;
515511 config -> pass_set = -1 ;
516512 config -> pool = pool ;
513+ config -> show_rule_ids = -1 ;
517514 }
518515
519516 return config ;
@@ -537,12 +534,24 @@ static void *merge_redirectionio_dir_conf(apr_pool_t *pool, void *parent, void *
537534 conf -> enable_logs = conf_current -> enable_logs ;
538535 }
539536
537+ if (conf_current -> show_rule_ids == -1 ) {
538+ conf -> show_rule_ids = conf_parent -> show_rule_ids ;
539+ } else {
540+ conf -> show_rule_ids = conf_current -> show_rule_ids ;
541+ }
542+
540543 if (conf_current -> project_key == NULL ) {
541544 conf -> project_key = conf_parent -> project_key ;
542545 } else {
543546 conf -> project_key = conf_current -> project_key ;
544547 }
545548
549+ if (conf_current -> scheme == NULL ) {
550+ conf -> scheme = conf_parent -> scheme ;
551+ } else {
552+ conf -> scheme = conf_current -> scheme ;
553+ }
554+
546555 if (conf_current -> pass_set == -1 ) {
547556 conf -> port = conf_parent -> port ;
548557 conf -> protocol = conf_parent -> protocol ;
@@ -621,6 +630,10 @@ static const char *redirectionio_set_enable(cmd_parms *cmd, void *cfg, const cha
621630 if (conf -> enable_logs == -1 ) {
622631 conf -> enable_logs = 1 ;
623632 }
633+
634+ if (conf -> show_rule_ids == -1 ) {
635+ conf -> show_rule_ids = 0 ;
636+ }
624637 } else {
625638 conf -> enable = 0 ;
626639 }
@@ -647,6 +660,16 @@ static const char *redirectionio_set_project_key(cmd_parms *cmd, void *cfg, cons
647660 return NULL ;
648661}
649662
663+ static const char * redirectionio_set_scheme (cmd_parms * cmd , void * cfg , const char * arg ) {
664+ redirectionio_config * conf = (redirectionio_config * )cfg ;
665+
666+ if (conf ) {
667+ conf -> scheme = arg ;
668+ }
669+
670+ return NULL ;
671+ }
672+
650673static const char * redirectionio_set_logs_enable (cmd_parms * cmd , void * cfg , const char * arg ) {
651674 redirectionio_config * conf = (redirectionio_config * )cfg ;
652675
@@ -661,6 +684,20 @@ static const char *redirectionio_set_logs_enable(cmd_parms *cmd, void *cfg, cons
661684 return NULL ;
662685}
663686
687+ static const char * redirectionio_set_show_rule_ids (cmd_parms * cmd , void * cfg , const char * arg ) {
688+ redirectionio_config * conf = (redirectionio_config * )cfg ;
689+
690+ if (conf ) {
691+ if (!strcasecmp (arg , "on" )) {
692+ conf -> show_rule_ids = 1 ;
693+ } else {
694+ conf -> show_rule_ids = 0 ;
695+ }
696+ }
697+
698+ return NULL ;
699+ }
700+
664701static const char * redirectionio_set_pass (cmd_parms * cmd , void * cfg , const char * arg ) {
665702 apr_uri_t uri ;
666703 redirectionio_config * conf = (redirectionio_config * )cfg ;
0 commit comments