1.修改hijack表读取问题
2.修改table_info关于策略文件配置问题
This commit is contained in:
@@ -84,8 +84,8 @@ enum pangu_http_stat
|
||||
enum manipulate_profile_table
|
||||
{
|
||||
POLICY_PROFLIE_TABLE_REJECT,
|
||||
POLICY_PROFILE_TABLE_HIJACK,
|
||||
POLICY_PROFILE_TABLE_INSERT,
|
||||
POLICY_PROFILE_TABLE_HIJACK,
|
||||
POLICY_PROFILE_TABLE_MAX
|
||||
};
|
||||
|
||||
@@ -648,6 +648,40 @@ void ma_profile_table_new_cb(int table_id, const char* key, const char* table_li
|
||||
ply_profile->profile_name=tfe_strdup(profile_name);
|
||||
ply_profile->profile_type=tfe_strdup(formate);
|
||||
|
||||
TFE_LOG_INFO(g_pangu_rt->local_logger, "Policy table add success %d", profile_id);
|
||||
|
||||
*ad = ply_profile;
|
||||
return;
|
||||
}
|
||||
|
||||
void ma_hijack_profile_table_new_cb(int table_id, const char* key, const char* table_line, MAAT_PLUGIN_EX_DATA* ad, long argl, void* argp)
|
||||
{
|
||||
int ret=0, profile_id=0, is_valid=0;
|
||||
char profile_name[128]={0}, formate[128]={0};
|
||||
char profile_path[TFE_PATH_MAX]={0},hijack_name[128]={0};
|
||||
|
||||
ret=sscanf(table_line, "%d\t%s\t%s\t%s\t%s\t%d", &profile_id, profile_name, hijack_name, formate, profile_path, &is_valid);
|
||||
if(ret!=6)
|
||||
{
|
||||
TFE_LOG_ERROR(g_pangu_rt->local_logger, "Policy table parse config failed: %s", table_line);
|
||||
return;
|
||||
}
|
||||
struct manipulate_profile* ply_profile=ALLOC(struct manipulate_profile, 1);
|
||||
memset(ply_profile, 0, sizeof(struct manipulate_profile));
|
||||
|
||||
ply_profile->profile_id=profile_id;
|
||||
ply_profile->ref_cnt=1;
|
||||
|
||||
ply_profile->profile_msg = execute_read_file(profile_path, &ply_profile->msg_len);
|
||||
if (ply_profile->profile_msg == NULL)
|
||||
{
|
||||
TFE_LOG_ERROR(g_pangu_rt->local_logger, "Read file failed %d:%s:%s", profile_id, profile_name, profile_path);
|
||||
}
|
||||
ply_profile->profile_name=tfe_strdup(hijack_name);
|
||||
ply_profile->profile_type=tfe_strdup(formate);
|
||||
|
||||
TFE_LOG_INFO(g_pangu_rt->local_logger, "Policy table add success %d", profile_id);
|
||||
|
||||
*ad = ply_profile;
|
||||
return;
|
||||
}
|
||||
@@ -701,8 +735,8 @@ int maat_table_ex_init(int profile_idx,
|
||||
{
|
||||
int table_id = 0;
|
||||
const char *table_name_map[] = {"PXY_PROFILE_RESPONSE_PAGES",
|
||||
"PXY_PROFILE_HIJACK_FILES",
|
||||
"PXY_PROFILE_INSERT_SCRIPTS"};
|
||||
"PXY_PROFILE_INSERT_SCRIPTS",
|
||||
"PXY_PROFILE_HIJACK_FILES"};
|
||||
|
||||
table_id=g_pangu_rt->plolicy_table_id[profile_idx]=Maat_table_register(g_pangu_rt->maat, table_name_map[profile_idx]);
|
||||
if(table_id >= 0)
|
||||
@@ -778,7 +812,7 @@ int pangu_policy_init(const char* profile_path, const char* static_section, cons
|
||||
}
|
||||
|
||||
|
||||
for (profile_table_idx = 0; profile_table_idx <POLICY_PROFILE_TABLE_MAX; profile_table_idx++)
|
||||
for (profile_table_idx = 0; profile_table_idx <=POLICY_PROFILE_TABLE_INSERT; profile_table_idx++)
|
||||
{
|
||||
ret = maat_table_ex_init(profile_table_idx,
|
||||
ma_profile_table_new_cb,
|
||||
@@ -789,6 +823,16 @@ int pangu_policy_init(const char* profile_path, const char* static_section, cons
|
||||
goto error_out;
|
||||
}
|
||||
}
|
||||
|
||||
ret = maat_table_ex_init(POLICY_PROFILE_TABLE_HIJACK,
|
||||
ma_hijack_profile_table_new_cb,
|
||||
ma_profile_table_free_cb,
|
||||
ma_profile_table_dup_cb);
|
||||
if(ret<0)
|
||||
{
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
g_pangu_rt->dyn_maat = create_maat_feather("dyn", profile_path, dynamic_section, g_pangu_rt->thread_num, g_pangu_rt->local_logger);
|
||||
if (!g_pangu_rt->maat)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user