diff options
Diffstat (limited to 'plugin/business/tsg-http/src/tsg_logger.cpp')
| -rw-r--r-- | plugin/business/tsg-http/src/tsg_logger.cpp | 47 |
1 files changed, 17 insertions, 30 deletions
diff --git a/plugin/business/tsg-http/src/tsg_logger.cpp b/plugin/business/tsg-http/src/tsg_logger.cpp index 258c184..3e25f82 100644 --- a/plugin/business/tsg-http/src/tsg_logger.cpp +++ b/plugin/business/tsg-http/src/tsg_logger.cpp @@ -29,17 +29,18 @@ struct proxy_logger struct cache_evbase_instance * log_file_upload_instance; }; -enum _log_action //Bigger action number is prior. +enum _log_action { - LG_ACTION_NONE = 0x00, - LG_ACTION_MONIT = 0x01, - LG_ACTION_FORWARD = 0x02, /* N/A */ - LG_ACTION_REJECT = 0x10, - LG_ACTION_DROP = 0x20, /* N/A */ - LG_ACTION_MANIPULATE = 0x30, - LG_ACTION_RATELIMIT = 0x40, /* N/A */ - LG_ACTION_WHITELIST = 0x60, - LG_ACTION_SHUNT = 0x80, + LG_ACTION_NONE = 0, + LG_ACTION_DENY = 1, + LG_ACTION_ALLOW = 2, + LG_ACTION_MONITOR = 3, + LG_ACTION_REDIRECT = 4, + LG_ACTION_REPLACE = 5, + LG_ACTION_HIJACK = 6, + LG_ACTION_REJECT = 7, + LG_ACTION_EDIT_ELEMENT = 8, + LG_ACTION_RUN_SCRIPT = 9, __LG_ACTION_MAX }; @@ -213,13 +214,7 @@ int proxy_send_log(struct proxy_logger* handle, const struct proxy_log* log_msg) char dst_ip_str[MAX(INET6_ADDRSTRLEN,INET_ADDRSTRLEN)] = {0}; const char *app_proto[]= {"unkonw","http1", "http2"}; - - const char *manipulate_action_map[]= {"redirect","block","replace","hijack","insert","edit_element","run_script"}; - - const char *panggu_action_map[__LG_ACTION_MAX]; - panggu_action_map[LG_ACTION_MONIT]="monitor"; - panggu_action_map[LG_ACTION_REJECT]="deny"; - panggu_action_map[LG_ACTION_WHITELIST]="allow"; + const char *manipulate_action_map[]= {"none","deny","allow","monitor","redirect","replace","hijack","inject","edit_element","run_script"}; struct json_spec req_fields[]={ {"http_cookie", TFE_HTTP_COOKIE}, {"http_referer", TFE_HTTP_REFERER}, @@ -359,7 +354,7 @@ int proxy_send_log(struct proxy_logger* handle, const struct proxy_log* log_msg) char *monit_config_id[16]={0}; for(size_t i=0; i<log_msg->result_num; i++) { - if(log_msg->result[i].action == LG_ACTION_MONIT) + if(log_msg->result[i].action == LG_ACTION_MONITOR) { monit_config_id[j]=log_msg->result[i].config_uuid_string; j++; @@ -379,7 +374,7 @@ int proxy_send_log(struct proxy_logger* handle, const struct proxy_log* log_msg) continue; } - if(log_msg->result[i].action == LG_ACTION_MONIT && enable_monit==1) + if(log_msg->result[i].action == LG_ACTION_MONITOR && enable_monit==1) { continue; } @@ -387,7 +382,7 @@ int proxy_send_log(struct proxy_logger* handle, const struct proxy_log* log_msg) cJSON *proxy_rule_list=NULL; char *config_id[1]={0}; per_hit_obj=cJSON_Duplicate(common_obj, 1); - if(log_msg->result[i].action == LG_ACTION_MONIT) + if(log_msg->result[i].action == LG_ACTION_MONITOR) { proxy_rule_list = cJSON_CreateStringArray((const char **)monit_config_id, j); enable_monit=1; @@ -399,16 +394,8 @@ int proxy_send_log(struct proxy_logger* handle, const struct proxy_log* log_msg) } cJSON_AddItemToObject(per_hit_obj, "proxy_rule_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) - { - cJSON_AddStringToObject(per_hit_obj, "proxy_action", manipulate_action_map[log_msg->action]); - cJSON_AddNumberToObject(per_hit_obj, "http_action_file_size", log_msg->inject_sz); - } - else - { - cJSON_AddStringToObject(per_hit_obj, "proxy_action", panggu_action_map[(unsigned char)(log_msg->result[i].action)]); - } - + cJSON_AddStringToObject(per_hit_obj, "proxy_action", manipulate_action_map[log_msg->result[i].action]); + cJSON_AddNumberToObject(per_hit_obj, "http_action_file_size", log_msg->inject_sz); log_payload = cJSON_PrintUnformatted(per_hit_obj); TFE_LOG_DEBUG(handle->local_logger, "%s", log_payload); |
