This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
tango-tfe/plugin/business/pangu-http/pangu_http.cpp
2018-09-09 15:23:23 +08:00

68 lines
2.6 KiB
C++

enum HttpActionType
{
kActionBypass = 0x00,
kActionMonitor = 0x01,
kActionBlock = 0x10,
kActionDrop = 0x20,
kActionRedirect = 0x30,
kActionRateLimit = 0x40,
kActionReplace = 0x50,
kActionWhiteList = 0x80,
kActionMax = 0xff
};
Maat_feather_t init_maat(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 ret=0,scan_detail=0,effect_interval=60;
char table_info[MAX_PATH_LEN]={0},inc_cfg_dir[MAX_PATH_LEN]={0},ful_cfg_dir[MAX_PATH_LEN]={0};
char json_cfg_file[MAX_PATH_LEN]={0},maat_stat_file[MAX_PATH_LEN]={0};
const char* instance_name="soq";
MESA_load_profile_int_def(profile, section,"MAAT_JSON_SWITCH", &(maat_json_switch),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,"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);
effect_interval*=1000;//convert s to ms
assert(strlen(inc_cfg_dir)!=0&&strlen(ful_cfg_dir)!=0);
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)
{
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);
}
if(maat_stat_on)
{
Maat_set_feather_opt(target, MAAT_OPT_STAT_FILE_PATH, maat_stat_file, strlen(maat_stat_file)+1);
Maat_set_feather_opt(target, MAAT_OPT_STAT_ON, NULL, 0);
if(maat_perf_on)
{
Maat_set_feather_opt(target, MAAT_OPT_PERF_ON, NULL, 0);
}
}
Maat_set_feather_opt(target, MAAT_OPT_EFFECT_INVERVAL_MS, &effect_interval, sizeof(effect_interval));
//t1 or t2 do not care hit position.
Maat_set_feather_opt(target, MAAT_OPT_SCAN_DETAIL, &scan_detail, sizeof(scan_detail));
ret=Maat_initiate_feather(target);
if(ret<0)
{
return NULL;
}
return target;
}