1.修复insert获取无效值问题
2.修复一期二期REJECT和block接口替换
This commit is contained in:
@@ -97,7 +97,7 @@ struct manipulate_profile
|
|||||||
char *profile_name;
|
char *profile_name;
|
||||||
char *profile_msg;
|
char *profile_msg;
|
||||||
char *profile_type;
|
char *profile_type;
|
||||||
ctemplate::Template * tpl;
|
ctemplate::Template * tpl;
|
||||||
pthread_mutex_t lock;
|
pthread_mutex_t lock;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -639,9 +639,9 @@ void ma_profile_table_new_cb(int table_id, const char* key, const char* table_li
|
|||||||
memset(ply_profile, 0, sizeof(struct manipulate_profile));
|
memset(ply_profile, 0, sizeof(struct manipulate_profile));
|
||||||
|
|
||||||
ply_profile->profile_id=profile_id;
|
ply_profile->profile_id=profile_id;
|
||||||
ply_profile->ref_cnt=1;
|
ply_profile->ref_cnt=1;
|
||||||
pthread_mutex_init(&(ply_profile->lock), NULL);
|
pthread_mutex_init(&(ply_profile->lock), NULL);
|
||||||
|
|
||||||
if(strcasecmp(formate, "template") == 0)
|
if(strcasecmp(formate, "template") == 0)
|
||||||
{
|
{
|
||||||
ply_profile->tpl = ctemplate::Template::GetTemplate(profile_path, ctemplate::DO_NOT_STRIP);
|
ply_profile->tpl = ctemplate::Template::GetTemplate(profile_path, ctemplate::DO_NOT_STRIP);
|
||||||
@@ -675,7 +675,7 @@ void ma_hijack_profile_table_new_cb(int table_id, const char* key, const char* t
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
struct manipulate_profile* ply_profile=ALLOC(struct manipulate_profile, 1);
|
struct manipulate_profile* ply_profile=ALLOC(struct manipulate_profile, 1);
|
||||||
ply_profile->ref_cnt=1;
|
ply_profile->ref_cnt=1;
|
||||||
pthread_mutex_init(&(ply_profile->lock), NULL);
|
pthread_mutex_init(&(ply_profile->lock), NULL);
|
||||||
|
|
||||||
ply_profile->profile_id=profile_id;
|
ply_profile->profile_id=profile_id;
|
||||||
@@ -705,7 +705,7 @@ void ma_profile_table_free_cb(int table_id, MAAT_PLUGIN_EX_DATA* ad, long argl,
|
|||||||
}
|
}
|
||||||
pthread_mutex_unlock(&(ply_obj->lock));
|
pthread_mutex_unlock(&(ply_obj->lock));
|
||||||
pthread_mutex_destroy(&(ply_obj->lock));
|
pthread_mutex_destroy(&(ply_obj->lock));
|
||||||
|
|
||||||
FREE(&ply_obj->profile_type);
|
FREE(&ply_obj->profile_type);
|
||||||
FREE(&ply_obj->profile_msg);
|
FREE(&ply_obj->profile_msg);
|
||||||
FREE(&ply_obj->profile_name);
|
FREE(&ply_obj->profile_name);
|
||||||
@@ -1431,7 +1431,7 @@ void http_replace(const struct tfe_stream * stream, const struct tfe_http_sessio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void http_reject(const struct tfe_http_session * session, enum tfe_http_event events,
|
static UNUSED void http_reject(const struct tfe_http_session * session, enum tfe_http_event events,
|
||||||
struct pangu_http_ctx * ctx)
|
struct pangu_http_ctx * ctx)
|
||||||
{
|
{
|
||||||
int resp_code = 0;
|
int resp_code = 0;
|
||||||
@@ -1528,7 +1528,7 @@ static void http_block(const struct tfe_http_session * session, enum tfe_http_ev
|
|||||||
int profile_id = param->profile_id;
|
int profile_id = param->profile_id;
|
||||||
char *message = param->message;
|
char *message = param->message;
|
||||||
|
|
||||||
if (resp_code <= 0 || profile_id <= 0){
|
if (resp_code <= 0 || profile_id < 0){
|
||||||
TFE_LOG_ERROR(g_pangu_rt->local_logger, "Invalid block rule %d", ctx->enforce_rules[0].config_id);
|
TFE_LOG_ERROR(g_pangu_rt->local_logger, "Invalid block rule %d", ctx->enforce_rules[0].config_id);
|
||||||
ctx->action = PG_ACTION_NONE;
|
ctx->action = PG_ACTION_NONE;
|
||||||
return;
|
return;
|
||||||
@@ -1544,8 +1544,8 @@ static void http_block(const struct tfe_http_session * session, enum tfe_http_ev
|
|||||||
ret = html_generate(profile_id, message, &page_buff, &page_size);
|
ret = html_generate(profile_id, message, &page_buff, &page_size);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
{
|
{
|
||||||
TFE_LOG_ERROR(g_pangu_rt->local_logger, "Failed to get policy table, table_id = %d", profile_id);
|
/*read local configuration**/
|
||||||
ctx->action = PG_ACTION_NONE;
|
template_generate(resp_code, ctx->enforce_rules[0].config_id, message, &page_buff, &page_size);
|
||||||
}
|
}
|
||||||
tfe_http_std_field_write(response, TFE_HTTP_CONT_TYPE, "text/html; charset=utf-8");
|
tfe_http_std_field_write(response, TFE_HTTP_CONT_TYPE, "text/html; charset=utf-8");
|
||||||
snprintf(cont_len_str, sizeof(cont_len_str), "%lu", page_size);
|
snprintf(cont_len_str, sizeof(cont_len_str), "%lu", page_size);
|
||||||
@@ -1740,7 +1740,7 @@ static void http_insert(const struct tfe_stream * stream, const struct tfe_http_
|
|||||||
rewrite_buff = NULL;
|
rewrite_buff = NULL;
|
||||||
rewrite_sz = 0;
|
rewrite_sz = 0;
|
||||||
|
|
||||||
if (strstr(cont_type_val, "text/html") != NULL)
|
if (cont_type_val != NULL && strstr(cont_type_val, "text/html") != NULL)
|
||||||
{
|
{
|
||||||
rewrite_sz = execute_insert_rule(http_body, http_body_len, ins_ctx->rule, &rewrite_buff);
|
rewrite_sz = execute_insert_rule(http_body, http_body_len, ins_ctx->rule, &rewrite_buff);
|
||||||
}
|
}
|
||||||
@@ -1934,7 +1934,7 @@ void enforce_control_policy(const struct tfe_stream * stream, const struct tfe_h
|
|||||||
//send log on close.
|
//send log on close.
|
||||||
break;
|
break;
|
||||||
case PG_ACTION_REJECT:
|
case PG_ACTION_REJECT:
|
||||||
http_reject(session, events, ctx);
|
http_block(session, events, ctx);
|
||||||
ATOMIC_INC(&(g_pangu_rt->stat_val[STAT_ACTION_REJECT]));
|
ATOMIC_INC(&(g_pangu_rt->stat_val[STAT_ACTION_REJECT]));
|
||||||
break;
|
break;
|
||||||
case PG_ACTION_MANIPULATE:
|
case PG_ACTION_MANIPULATE:
|
||||||
|
|||||||
Reference in New Issue
Block a user