summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/src/tfe_fieldstat.cpp4
-rw-r--r--plugin/business/doh/src/doh.cpp2
-rw-r--r--plugin/business/doh/src/logger.cpp2
-rw-r--r--plugin/business/tsg-http/src/tsg_http.cpp126
-rw-r--r--plugin/business/tsg-http/src/tsg_logger.cpp2
5 files changed, 74 insertions, 62 deletions
diff --git a/common/src/tfe_fieldstat.cpp b/common/src/tfe_fieldstat.cpp
index e63e94c..8af2ee0 100644
--- a/common/src/tfe_fieldstat.cpp
+++ b/common/src/tfe_fieldstat.cpp
@@ -110,7 +110,7 @@ int tfe_fieldstat_intercept_incrby(struct fieldstat_easy_intercept *metrics, voi
nr_tags++;
}
// action : 2 Intercept; 3 No Intercept
- FIELDSTAT_TAG_INIT(tags, nr_tags, "action", FIELD_VALUE_INTEGER, (hit_no_intercept == 1 ? 3 : 2));
+ FIELDSTAT_TAG_STR(tags, nr_tags, "action", FIELD_VALUE_CSTRING, (hit_no_intercept == 1 ? "no_intercept" : "intercept"));
nr_tags++;
if (hit_count > 0)
@@ -216,7 +216,7 @@ struct fieldstat_easy_intercept *tfe_fieldstat_easy_intercept_create(char *app_n
struct filedstat_easy_manipulation *tfe_fieldstat_easy_manipulation_create(char *app_name, char *outpath, int cycle, int max_thread, void *local_logger)
{
const char *counter_field[COLUMN_MAX] = {"hit_count", "in_bytes", "out_bytes", "in_pkts", "out_pkts"};
- struct field metric_tags[TAG_MAX - 1] = {{"vsys_id", FIELD_VALUE_INTEGER, -1}, {"rule_uuid", FIELD_VALUE_CSTRING, -1}, {"action", FIELD_VALUE_INTEGER, -1}, {"sub_action", FIELD_VALUE_CSTRING, -1}};
+ struct field metric_tags[TAG_MAX - 1] = {{"vsys_id", FIELD_VALUE_INTEGER, -1}, {"rule_uuid", FIELD_VALUE_CSTRING, -1}, {"action", FIELD_VALUE_CSTRING, -1}, {"sub_action", FIELD_VALUE_CSTRING, -1}};
struct filedstat_easy_manipulation *fieldstat = ALLOC(struct filedstat_easy_manipulation, 1);
diff --git a/plugin/business/doh/src/doh.cpp b/plugin/business/doh/src/doh.cpp
index f09ac0f..50b5cd9 100644
--- a/plugin/business/doh/src/doh.cpp
+++ b/plugin/business/doh/src/doh.cpp
@@ -813,7 +813,7 @@ void doh_send_metric_log(const struct tfe_stream * stream, struct doh_ctx *ctx,
fieldstat->tags[thread_id][TAG_VSYS_ID].value_longlong = ctx->result->vsys_id;
fieldstat->tags[thread_id][TAG_RULE_ID].value_str = ctx->result->config_uuid_string;
- fieldstat->tags[thread_id][TAG_ACTION].value_longlong = 48;
+ fieldstat->tags[thread_id][TAG_ACTION].value_str = "manipulate";
fieldstat->tags[thread_id][TAG_SUB_ACTION].value_str = "redirect";
tfe_stream_info_get(stream, INFO_FROM_DOWNSTREAM_RX_OFFSET, &c2s_byte_num, sizeof(c2s_byte_num));
diff --git a/plugin/business/doh/src/logger.cpp b/plugin/business/doh/src/logger.cpp
index f11335c..12d383a 100644
--- a/plugin/business/doh/src/logger.cpp
+++ b/plugin/business/doh/src/logger.cpp
@@ -476,7 +476,7 @@ int doh_send_log(struct doh_conf *handle, const struct tfe_http_session *http, c
per_hit_obj = cJSON_Duplicate(common_obj, 1);
config_id[0]=result[i].config_uuid_string;
proxy_rule_list = cJSON_CreateStringArray((const char **)config_id, 1);
- cJSON_AddItemToObject(per_hit_obj, "proxy_rule_list", proxy_rule_list);
+ cJSON_AddItemToObject(per_hit_obj, "proxy_rule_uuid_list", proxy_rule_list);
cJSON_AddStringToObject(per_hit_obj, "proxy_action", "redirect");
log_payload = cJSON_PrintUnformatted(per_hit_obj);
diff --git a/plugin/business/tsg-http/src/tsg_http.cpp b/plugin/business/tsg-http/src/tsg_http.cpp
index 02b28ce..d468699 100644
--- a/plugin/business/tsg-http/src/tsg_http.cpp
+++ b/plugin/business/tsg-http/src/tsg_http.cpp
@@ -461,57 +461,9 @@ unsigned char log_option_type_str2idx(const char *log_option)
return i;
}
-void policy_action_param_new(const char *table_name, const char* key, const char* table_line, void **ad, long argl, void* argp)
+void policy_set_param_by_action(struct policy_action_param* param, cJSON *action_parameter)
{
- cJSON* pxy_ctrl_rule = cJSON_Parse(table_line);
- if(pxy_ctrl_rule == NULL)
- {
- TFE_LOG_ERROR(g_proxy_rt->local_logger, "PXY_CTRL_RULE parse table_line failed. table_line:%s", table_line);
- return;
- }
-
- struct policy_action_param* param=ALLOC(struct policy_action_param, 1);
-
- cJSON *uuid = cJSON_GetObjectItem(pxy_ctrl_rule, "uuid");
- if(uuid && uuid->type==cJSON_String)
- {
- param->hit_rule.config_uuid_string = strdup(uuid->valuestring);
- uuid_parse(uuid->valuestring, param->hit_rule.config_uuid);
- }
-
- cJSON *action = cJSON_GetObjectItem(pxy_ctrl_rule, "action");
- if(action && action->type==cJSON_String)
- {
- param->hit_rule.action=action_type_str2idx(action->valuestring);
- }
-
- cJSON *blacklist_option = cJSON_GetObjectItem(pxy_ctrl_rule, "blacklist_option");
- if(blacklist_option && blacklist_option->type==cJSON_Number)
- {
- param->hit_rule.do_blacklist=blacklist_option->valueint;
- }
-
- cJSON *log_option = cJSON_GetObjectItem(pxy_ctrl_rule, "log_option");
- if(log_option && log_option->type==cJSON_String)
- {
- param->hit_rule.do_log=log_option_type_str2idx(log_option->valuestring);
- }
-
- cJSON *action_parameter = cJSON_GetObjectItem(pxy_ctrl_rule, "action_parameter");
- if(action_parameter == NULL || action_parameter->type!=cJSON_Object)
- {
- FREE(&param);
- TFE_LOG_ERROR(g_proxy_rt->local_logger, "invalid policy parameter: id = %s", param->hit_rule.config_uuid_string);
- return;
- }
-
- param->ref_cnt=1;
- pthread_mutex_init(&(param->lock), NULL);
- param->hit_rule.action_parameter = cJSON_PrintUnformatted(action_parameter);
-
- int rule_id=0;
- cJSON *rules=NULL, *item=NULL, *sub_item=NULL;
-
+ cJSON *item=NULL;
switch(param->hit_rule.action)
{
case PX_ACTION_REDIRECT:
@@ -586,13 +538,13 @@ void policy_action_param_new(const char *table_name, const char* key, const char
default:
break;
}
+ return;
+}
- cJSON *method=cJSON_GetObjectItem(action_parameter, "sub_action");
- if(method && method->type==cJSON_String)
- {
- param->action=manipulate_action_str2idx(method->valuestring);
- }
-
+void policy_set_param_by_sub_action(struct policy_action_param* param, cJSON *action_parameter)
+{
+ int rule_id=0;
+ cJSON *rules=NULL, *item=NULL, *sub_item=NULL;
switch(param->action)
{
case MA_ACTION_REPLACE_TEXT:
@@ -748,6 +700,66 @@ void policy_action_param_new(const char *table_name, const char* key, const char
default:
break;
}
+
+ return;
+}
+
+void policy_action_param_new(const char *table_name, const char* key, const char* table_line, void **ad, long argl, void* argp)
+{
+ cJSON* pxy_ctrl_rule = cJSON_Parse(table_line);
+ if(pxy_ctrl_rule == NULL)
+ {
+ TFE_LOG_ERROR(g_proxy_rt->local_logger, "PXY_CTRL_RULE parse table_line failed. table_line:%s", table_line);
+ return;
+ }
+
+ struct policy_action_param* param=ALLOC(struct policy_action_param, 1);
+
+ cJSON *uuid = cJSON_GetObjectItem(pxy_ctrl_rule, "uuid");
+ if(uuid && uuid->type==cJSON_String)
+ {
+ param->hit_rule.config_uuid_string = strdup(uuid->valuestring);
+ uuid_parse(uuid->valuestring, param->hit_rule.config_uuid);
+ }
+
+ cJSON *action = cJSON_GetObjectItem(pxy_ctrl_rule, "action");
+ if(action && action->type==cJSON_String)
+ {
+ param->hit_rule.action=action_type_str2idx(action->valuestring);
+ }
+
+ cJSON *blacklist_option = cJSON_GetObjectItem(pxy_ctrl_rule, "blacklist_option");
+ if(blacklist_option && blacklist_option->type==cJSON_Number)
+ {
+ param->hit_rule.do_blacklist=blacklist_option->valueint;
+ }
+
+ cJSON *log_option = cJSON_GetObjectItem(pxy_ctrl_rule, "log_option");
+ if(log_option && log_option->type==cJSON_String)
+ {
+ param->hit_rule.do_log=log_option_type_str2idx(log_option->valuestring);
+ }
+
+ cJSON *action_parameter = cJSON_GetObjectItem(pxy_ctrl_rule, "action_parameter");
+ if(action_parameter == NULL || action_parameter->type!=cJSON_Object)
+ {
+ FREE(&param);
+ TFE_LOG_ERROR(g_proxy_rt->local_logger, "invalid policy parameter: id = %s", param->hit_rule.config_uuid_string);
+ return;
+ }
+
+ param->ref_cnt=1;
+ pthread_mutex_init(&(param->lock), NULL);
+ param->hit_rule.action_parameter = cJSON_PrintUnformatted(action_parameter);
+ policy_set_param_by_action(param, action_parameter);
+
+ cJSON *method=cJSON_GetObjectItem(action_parameter, "sub_action");
+ if(method && method->type==cJSON_String)
+ {
+ param->action=manipulate_action_str2idx(method->valuestring);
+ }
+ policy_set_param_by_sub_action(param, action_parameter);
+
*ad=param;
TFE_LOG_INFO(g_proxy_rt->local_logger, "Add ctrl policy: %s", param->hit_rule.config_uuid_string);
cJSON_Delete(pxy_ctrl_rule);
@@ -1519,7 +1531,7 @@ void proxy_send_metric_log(const struct tfe_stream * stream, struct proxy_http_c
{
fieldstat->tags[thread_id][TAG_VSYS_ID].value_longlong = ctx->enforce_rules[i].vsys_id;
fieldstat->tags[thread_id][TAG_RULE_ID].value_str = ctx->enforce_rules[i].config_uuid_string;
- fieldstat->tags[thread_id][TAG_ACTION].value_longlong = PX_ACTION_MANIPULATE;
+ fieldstat->tags[thread_id][TAG_ACTION].value_str = "manipulate";
if(ctx->enforce_rules[i].action == PX_ACTION_MANIPULATE)
{
fieldstat->tags[thread_id][TAG_SUB_ACTION].value_str = manipulate_action_map[ctx->param->action];
diff --git a/plugin/business/tsg-http/src/tsg_logger.cpp b/plugin/business/tsg-http/src/tsg_logger.cpp
index 256a5d5..5511200 100644
--- a/plugin/business/tsg-http/src/tsg_logger.cpp
+++ b/plugin/business/tsg-http/src/tsg_logger.cpp
@@ -391,7 +391,7 @@ int proxy_send_log(struct proxy_logger* handle, const struct proxy_log* log_msg)
config_id[0]=log_msg->result[i].config_uuid_string;
proxy_rule_list = cJSON_CreateStringArray((const char **)config_id, 1);
}
- cJSON_AddItemToObject(per_hit_obj, "proxy_rule_list", proxy_rule_list);
+ cJSON_AddItemToObject(per_hit_obj, "proxy_rule_uuid_list", proxy_rule_list);
cJSON_AddNumberToObject(per_hit_obj, "vsys_id", log_msg->result[i].vsys_id);
if(log_msg->result[i].action == LG_ACTION_MANIPULATE)
{