1.修复insert获取无效值问题

2.修复一期二期REJECT和block接口替换
This commit is contained in:
fengweihao
2019-06-11 11:25:24 +08:00
parent f986119d35
commit f14214d056

View File

@@ -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: