调整pangu-http配置文件的目录结构。
This commit is contained in:
@@ -61,22 +61,37 @@ struct pangu_rt
|
||||
int page_size;
|
||||
};
|
||||
struct pangu_rt *g_pangu_rt;
|
||||
#define MAAT_INPUT_JSON 0
|
||||
#define MAAT_INPUT_REDIS 1
|
||||
#define MAAT_INPUT_FILE 2
|
||||
|
||||
static Maat_feather_t create_maat_feather(const char* profile, const char* section,int max_thread, void* logger)
|
||||
{
|
||||
Maat_feather_t target;
|
||||
int maat_json_switch=0,maat_stat_on=0,maat_perf_on=0;
|
||||
int input_mode=0,maat_stat_on=0,maat_perf_on=0;
|
||||
int ret=0,scan_detail=0,effect_interval=60;
|
||||
char table_info[TFE_STRING_MAX]={0},inc_cfg_dir[TFE_STRING_MAX]={0},ful_cfg_dir[TFE_STRING_MAX]={0};
|
||||
char redis_server[TFE_STRING_MAX]={0};
|
||||
int redis_port=0;
|
||||
int redis_db_idx=0;
|
||||
char json_cfg_file[TFE_STRING_MAX]={0},maat_stat_file[TFE_STRING_MAX]={0};
|
||||
const char* instance_name="pangu";
|
||||
MESA_load_profile_int_def(profile, section,"MAAT_JSON_SWITCH", &(maat_json_switch),0);
|
||||
MESA_load_profile_int_def(profile, section,"MAAT_INPUT_MODE", &(input_mode),0);
|
||||
MESA_load_profile_int_def(profile, section,"STAT_SWITCH", &(maat_stat_on),1);
|
||||
MESA_load_profile_int_def(profile, section,"PERF_SWITCH", &(maat_perf_on),1);
|
||||
|
||||
MESA_load_profile_string_def(profile,section,"TABLE_INFO",table_info, sizeof(table_info),"");
|
||||
|
||||
MESA_load_profile_string_def(profile,section,"JSON_CFG_FILE",json_cfg_file, sizeof(json_cfg_file),"");
|
||||
|
||||
MESA_load_profile_string_def(profile,section,"MAAT_REDIS_SERVER",redis_server, sizeof(redis_server),"");
|
||||
MESA_load_profile_int_def(profile,section,"MAAT_REDIS_PORT", &(redis_port),6379);
|
||||
MESA_load_profile_int_def(profile,section,"MAAT_REDIS_DB_INDEX", &(redis_db_idx),0);
|
||||
|
||||
|
||||
MESA_load_profile_string_def(profile,section,"INC_CFG_DIR",inc_cfg_dir, sizeof(inc_cfg_dir),"");
|
||||
MESA_load_profile_string_def(profile,section,"FULL_CFG_DIR",ful_cfg_dir, sizeof(ful_cfg_dir),"");
|
||||
MESA_load_profile_string_def(profile,section,"JSON_CFG_FILE",json_cfg_file, sizeof(json_cfg_file),"");
|
||||
|
||||
MESA_load_profile_string_def(profile,section,"STAT_FILE",maat_stat_file, sizeof(maat_stat_file),"");
|
||||
MESA_load_profile_int_def(profile,section,"EFFECT_INTERVAL_S", &(effect_interval),60);
|
||||
|
||||
@@ -85,14 +100,24 @@ static Maat_feather_t create_maat_feather(const char* profile, const char* secti
|
||||
|
||||
target=Maat_feather(max_thread,table_info, logger);
|
||||
Maat_set_feather_opt(target,MAAT_OPT_INSTANCE_NAME,instance_name, strlen(instance_name)+1);
|
||||
if(maat_json_switch==1)
|
||||
switch(input_mode)
|
||||
{
|
||||
Maat_set_feather_opt(target, MAAT_OPT_JSON_FILE_PATH, json_cfg_file, strlen(json_cfg_file)+1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Maat_set_feather_opt(target, MAAT_OPT_FULL_CFG_DIR, ful_cfg_dir, strlen(ful_cfg_dir)+1);
|
||||
Maat_set_feather_opt(target, MAAT_OPT_INC_CFG_DIR, inc_cfg_dir, strlen(inc_cfg_dir)+1);
|
||||
case MAAT_INPUT_JSON:
|
||||
Maat_set_feather_opt(target, MAAT_OPT_JSON_FILE_PATH, json_cfg_file, strlen(json_cfg_file)+1);
|
||||
break;
|
||||
case MAAT_INPUT_REDIS:
|
||||
Maat_set_feather_opt(target, MAAT_OPT_REDIS_IP,redis_server, strlen(redis_server)+1);
|
||||
Maat_set_feather_opt(target, MAAT_OPT_REDIS_PORT, &redis_port, sizeof(redis_port));
|
||||
Maat_set_feather_opt(target, MAAT_OPT_REDIS_INDEX, &redis_db_idx, sizeof(redis_db_idx));
|
||||
break;
|
||||
case MAAT_INPUT_FILE:
|
||||
Maat_set_feather_opt(target, MAAT_OPT_FULL_CFG_DIR, ful_cfg_dir, strlen(ful_cfg_dir)+1);
|
||||
Maat_set_feather_opt(target, MAAT_OPT_INC_CFG_DIR, inc_cfg_dir, strlen(inc_cfg_dir)+1);
|
||||
break;
|
||||
default:
|
||||
TFE_LOG_ERROR(logger, "Invalid MAAT Input Mode: %d.", input_mode);
|
||||
goto error_out;
|
||||
break;
|
||||
}
|
||||
if(maat_stat_on)
|
||||
{
|
||||
@@ -111,13 +136,16 @@ static Maat_feather_t create_maat_feather(const char* profile, const char* secti
|
||||
if(ret<0)
|
||||
{
|
||||
TFE_LOG_ERROR(logger, "%s MAAT init failed.", __FUNCTION__);
|
||||
return NULL;
|
||||
goto error_out;
|
||||
}
|
||||
return target;
|
||||
error_out:
|
||||
Maat_burn_feather(target);
|
||||
return NULL;
|
||||
}
|
||||
int pangu_http_init(struct tfe_proxy * proxy)
|
||||
{
|
||||
const char* profile="./pangu/pangu_pxy.conf";
|
||||
const char* profile="./pangu_conf/pangu_pxy.conf";
|
||||
const char* logfile="./log/pangu_pxy.log";
|
||||
g_pangu_rt=ALLOC(struct pangu_rt,1);
|
||||
MESA_load_profile_int_def(profile, "DEBUG", "LOG_LEVEL", &(g_pangu_rt->log_level),0);
|
||||
@@ -151,11 +179,11 @@ int pangu_http_init(struct tfe_proxy * proxy)
|
||||
}
|
||||
|
||||
char page_path[256];
|
||||
MESA_load_profile_string_def(profile, "TEMPLATE", "PAGE_403", page_path,sizeof(page_path), "./template/HTTP403.html");
|
||||
MESA_load_profile_string_def(profile, "TEMPLATE", "PAGE_403", page_path,sizeof(page_path), "./pangu_conf/template/HTTP403.html");
|
||||
g_pangu_rt->tpl_403 = ctemplate::Template::GetTemplate(page_path,ctemplate::DO_NOT_STRIP);
|
||||
MESA_load_profile_string_def(profile, "TEMPLATE", "PAGE_404", page_path,sizeof(page_path), "./template/HTTP404.html");
|
||||
MESA_load_profile_string_def(profile, "TEMPLATE", "PAGE_404", page_path,sizeof(page_path), "./pangu_conf/template/HTTP404.html");
|
||||
g_pangu_rt->tpl_404 = ctemplate::Template::GetTemplate(page_path,ctemplate::DO_NOT_STRIP);
|
||||
MESA_load_profile_string_def(profile, "TEMPLATE", "PAGE_451", page_path,sizeof(page_path), "./template/HTTP451.html");
|
||||
MESA_load_profile_string_def(profile, "TEMPLATE", "PAGE_451", page_path,sizeof(page_path), "./pangu_conf/template/HTTP451.html");
|
||||
g_pangu_rt->tpl_451 = ctemplate::Template::GetTemplate(page_path,ctemplate::DO_NOT_STRIP);
|
||||
|
||||
TFE_LOG_INFO(NULL, "Pangu HTTP init success.");
|
||||
@@ -866,7 +894,7 @@ void pangu_on_http_end(const struct tfe_stream * stream,
|
||||
struct pangu_log log_msg={.stream=stream, .http=session, .result=ctx->enforce_rules, .result_num=ctx->n_enforce};
|
||||
if(ctx->action!=PG_ACTION_NONE)
|
||||
{
|
||||
pangu_log_send(g_pangu_rt->send_logger, &log_msg);
|
||||
pangu_send_log(g_pangu_rt->send_logger, &log_msg);
|
||||
}
|
||||
pangu_http_ctx_free(ctx);
|
||||
*pme=NULL;
|
||||
|
||||
Reference in New Issue
Block a user