diff --git a/plugin/business/pangu-http/src/pangu_http.cpp b/plugin/business/pangu-http/src/pangu_http.cpp index c60fd4e..3097386 100644 --- a/plugin/business/pangu-http/src/pangu_http.cpp +++ b/plugin/business/pangu-http/src/pangu_http.cpp @@ -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 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) { diff --git a/resource/pangu/table_info.conf b/resource/pangu/table_info.conf index 9da1e97..2a137e6 100644 --- a/resource/pangu/table_info.conf +++ b/resource/pangu/table_info.conf @@ -30,7 +30,7 @@ 12 PXY_CACHE_HTTP_COOKIE expr UTF8 UTF8 yes 0 quickoff 13 PXY_PROFILE_TRUSTED_CA_CERT plugin {"valid":4,"foreign":"3"} 14 PXY_OBJ_TRUSTED_CA_CRL plugin {"valid":4,"foreign":"3"} -15 PXY_PROFILE_RESPONSE_PAGES plugin {"key":1,"valid":5} -16 PXY_PROFILE_HIJACK_FILES plugin {"key":1,"valid":5} -17 PXY_PROFILE_INSERT_SCRIPTS plugin {"key":1,"valid":5} +15 PXY_PROFILE_RESPONSE_PAGES plugin {"key":1,"foreign":"4","valid":5} +16 PXY_PROFILE_HIJACK_FILES plugin {"key":1,"foreign":"5","valid":6} +17 PXY_PROFILE_INSERT_SCRIPTS plugin {"key":1,"foreign":"4","valid":5} 18 PXY_INTERCEPT_COMPILE plugin {"key":1,"valid":8}