细化deny动作的执行

发送日志删除用户自定义域字段
This commit is contained in:
liuxueli
2020-01-19 15:53:02 +08:00
parent 791c2c270f
commit 15f70a849b
7 changed files with 308 additions and 106 deletions

View File

@@ -7,7 +7,6 @@ CB_SUBSCRIBER_IP_TABLE=TSG_DYN_SUBSCRIBER_IP
[TSG_LOG]
MODE=1
NIC_NAME=lo
MAX_SERVICE=1
LOG_LEVEL=10
LOG_PATH=./tsglog/tsglog
BROKER_LIST=192.168.40.186:9092

View File

@@ -7,3 +7,7 @@ DESTROY_FUNC=TSG_MASTER_UNLOAD
[TCP]
FUNC_FLAG=ALL
FUNC_NAME=TSG_MASTER_TCP_ENTRY
[UDP]
FUNC_FLAG=ALL
FUNC_NAME=TSG_MASTER_UDP_ENTRY

View File

@@ -39,7 +39,7 @@ static __attribute__((__used__)) const char * GIT_VERSION_UNKNOWN = NULL;
#endif
char TSG_MASTER_VERSION_20200117=0;
char TSG_MASTER_VERSION_20200119=0;
const char *tsg_conffile="tsgconf/main.conf";
g_tsg_para_t g_tsg_para;
@@ -58,6 +58,118 @@ static void free_policy_label(int thread_seq, void *project_req_value)
project_req_value=NULL;
}
static void free_context(void **pme, int thread_seq)
{
struct _master_context *_context=(struct _master_context *)*pme;
if(_context!=NULL)
{
if(_context->result!=NULL)
{
dictator_free(thread_seq, (void *)_context->result);
_context->result=NULL;
}
dictator_free(thread_seq, (void *)_context);
_context=NULL;
*pme=NULL;
}
}
static int init_context(void **pme, tsg_protocol_t proto, struct Maat_rule_t *p_result, int thread_seq)
{
struct _master_context *_context=(struct _master_context *)*pme;
*pme=dictator_malloc(thread_seq, sizeof(struct _master_context));
_context=(struct _master_context *)*pme;
_context->proto=proto;
_context->hit_cnt=1;
_context->result=(struct Maat_rule_t *)dictator_malloc(thread_seq, sizeof(struct Maat_rule_t));
memcpy(_context->result, p_result, sizeof(struct Maat_rule_t));
return 0;
}
static int master_method_type(struct streaminfo *a_stream, struct Maat_rule_t *p_result)
{
cJSON *item=NULL;
cJSON *object=NULL;
char *tmp_buff=NULL;
int method_type=-1;
if(p_result->serv_def_len<128)
{
object=cJSON_Parse(p_result->service_defined);
MESA_handle_runtime_log(g_tsg_para.logger,
RLOG_LV_DEBUG,
"DO_ACTION",
"Hit policy_id: %d service: %d action: %d user_reagion: %s addr: %s",
p_result->config_id,
p_result->service_id,
(unsigned char)p_result->action,
p_result->service_defined,
printaddr(&a_stream->addr, a_stream->threadnum)
);
}
else
{
tmp_buff=(char *)calloc(1, p_result->serv_def_len+1);
Maat_read_rule(g_tsg_maat_feather, p_result, MAAT_RULE_SERV_DEFINE, tmp_buff, p_result->serv_def_len);
object=cJSON_Parse(tmp_buff);
MESA_handle_runtime_log(g_tsg_para.logger,
RLOG_LV_DEBUG,
"DO_ACTION",
"Hit policy_id: %d service: %d action: %d user_reagion: %s addr: %s",
p_result->config_id,
p_result->service_id,
(unsigned char)p_result->action,
tmp_buff,
printaddr(&a_stream->addr, a_stream->threadnum)
);
}
if(object==NULL)
{
MESA_handle_runtime_log(g_tsg_para.logger,
RLOG_LV_FATAL,
"DO_ACTION",
"Hit policy_id: %d service: %d action: %d user_reagion: %s addr: %s",
p_result->config_id,
p_result->service_id,
(unsigned char)p_result->action,
(tmp_buff==NULL) ? p_result->service_defined : tmp_buff,
printaddr(&a_stream->addr, a_stream->threadnum)
);
if(tmp_buff!=NULL)
{
free(tmp_buff);
tmp_buff=NULL;
}
return -1;
}
item=cJSON_GetObjectItem(object, "method");
if(item!=NULL)
{
method_type=tsg_get_method_id(item->valuestring);
}
if(tmp_buff!=NULL)
{
free(tmp_buff);
tmp_buff=NULL;
}
cJSON_Delete(object);
object=NULL;
return method_type;
}
static char *schema_index2string(tsg_protocol_t proto)
{
char *schema_field_value=NULL;
@@ -249,7 +361,9 @@ static int identify_application_protocol(struct streaminfo *a_stream, struct _id
extern "C" char TSG_MASTER_TCP_ENTRY(struct streaminfo *a_tcp, void **pme, int thread_seq,void *a_packet)
{
int opt_value=0;
int ret=0,hit_num=0;
int method_type=-1;
int state=APP_STATE_DROPME;
scan_status_t mid=NULL;
Maat_rule_t *p_result=NULL;
@@ -257,6 +371,7 @@ extern "C" char TSG_MASTER_TCP_ENTRY(struct streaminfo *a_tcp, void **pme, int t
struct _identify_info identify_info;
Maat_rule_t all_result[MAX_RESULT_NUM];
policy_priority_label_t *priority_label=NULL;
struct rst_tcp_para rst_paras;
struct _master_context *_context=(struct _master_context *)*pme;
switch(a_tcp->opstate)
@@ -284,12 +399,11 @@ extern "C" char TSG_MASTER_TCP_ENTRY(struct streaminfo *a_tcp, void **pme, int t
RLOG_LV_DEBUG,
"SCAN_FQDN",
"Hit %s: %s policy_id: %d service: %d action: %d addr: %s",
(identify_info.proto==PROTO_HTTP) ? "host" : "sni",
identify_info.domain,
all_result[hit_num].config_id,
all_result[hit_num].service_id,
all_result[hit_num].action,
(unsigned char)all_result[hit_num].action,
printaddr(&a_tcp->addr, thread_seq)
);
@@ -316,7 +430,45 @@ extern "C" char TSG_MASTER_TCP_ENTRY(struct streaminfo *a_tcp, void **pme, int t
switch((unsigned char)p_result->action)
{
case TSG_ACTION_DENY:
MESA_kill_tcp(a_tcp, a_packet);
method_type=master_method_type(a_tcp, p_result);
switch(method_type)
{
case TSG_METHOD_TYPE_DROP:
opt_value=1;
MESA_set_stream_opt(a_tcp, MSO_DROP_STREAM, (void *)&opt_value, sizeof(opt_value));
state=PROT_STATE_DROPME|PROT_STATE_DROPPKT;
break;
case TSG_METHOD_TYPE_BLOCK:
MESA_handle_runtime_log(g_tsg_para.logger,
RLOG_LV_FATAL,
"TSG_ACTION_DENY",
"Unsupport block of deny, policy_id: %d service: %d action: %d addr: %s",
p_result[0].config_id,
p_result[0].service_id,
(unsigned char)all_result[hit_num].action,
printaddr(&a_tcp->addr, thread_seq)
);
//break; // not break
case TSG_METHOD_TYPE_RESET:
opt_value=1;
MESA_set_stream_opt(a_tcp, MSO_TCP_RST_REMEDY, (void *)&opt_value, sizeof(opt_value));
rst_paras.dir=DIR_DOUBLE;
rst_paras.rst_pkt_num=1;
rst_paras.signature_seed1=65535;
rst_paras.signature_seed2=13;
rst_paras.th_flags=4;
rst_paras.__pad_no_use=0;
MESA_rst_tcp(a_tcp, &rst_paras, sizeof(rst_paras));
opt_value=1;
MESA_set_stream_opt(a_tcp, MSO_DROP_STREAM, (void *)&opt_value, sizeof(opt_value));
MESA_set_stream_opt(a_tcp, MSO_TIMEOUT, (void *)&g_tsg_para.timeout, sizeof(g_tsg_para.timeout));
break;
default:
break;
}
FS_operate(g_tsg_para.fs2_handle, g_tsg_para.fs2_field_id[TSG_FS2_DENY], 0, FS_OP_ADD, 1);
master_send_log(a_tcp, p_result, 1, &identify_info, thread_seq);
@@ -325,33 +477,22 @@ extern "C" char TSG_MASTER_TCP_ENTRY(struct streaminfo *a_tcp, void **pme, int t
MESA_handle_runtime_log(g_tsg_para.logger,
RLOG_LV_DEBUG,
"DENY",
"Hit deny policy, policy_id: %d action: %d addr: %s",
"Hit deny policy, policy_id: %d service: %d action: %d addr: %s",
p_result[0].config_id,
p_result[0].action,
p_result[0].service_id,
(unsigned char)p_result[0].action,
printaddr(&a_tcp->addr, thread_seq)
);
break;
case TSG_ACTION_MONITOR:
if(q_result!=NULL && (p_result==q_result))
{
*pme=dictator_malloc(thread_seq, sizeof(struct _master_context));
_context=(struct _master_context *)*pme;
_context->proto=identify_info.proto;
_context->hit_cnt=1;
_context->result=(struct Maat_rule_t *)dictator_malloc(thread_seq, sizeof(struct Maat_rule_t));
memcpy(_context->result, p_result, sizeof(struct Maat_rule_t));
init_context(pme, identify_info.proto, p_result, thread_seq);
state=APP_STATE_GIVEME;
}
break;
case TSG_ACTION_BYPASS:
*pme=dictator_malloc(thread_seq, sizeof(struct _master_context));
_context=(struct _master_context *)*pme;
_context->proto=identify_info.proto;
_context->hit_cnt=1;
_context->result=(struct Maat_rule_t *)dictator_malloc(thread_seq, sizeof(struct Maat_rule_t));
memcpy(_context->result, p_result, sizeof(struct Maat_rule_t));
init_context(pme, identify_info.proto, p_result, thread_seq);
state=APP_STATE_GIVEME|APP_STATE_KILL_OTHER;
FS_operate(g_tsg_para.fs2_handle, g_tsg_para.fs2_field_id[TSG_FS2_BYPASS], 0, FS_OP_ADD, 1);
break;
@@ -373,12 +514,24 @@ extern "C" char TSG_MASTER_TCP_ENTRY(struct streaminfo *a_tcp, void **pme, int t
if(ret<0)
{
free_policy_label(thread_seq, (void *)priority_label);
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_FATAL, "PROJECT_ADD", "Add policy_priority_label failed ...");
MESA_handle_runtime_log(g_tsg_para.logger,
RLOG_LV_FATAL,
"PROJECT_ADD",
"Add policy_priority_label failed, intercept policy, policy_id: %d action: %d addr: %s",
priority_label->result[0].config_id,
(unsigned char)priority_label->result[0].action,
printaddr(&a_tcp->addr, thread_seq)
);
}
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_DEBUG, "INTERCEPT", "Hit intercept policy, policy_id: %d action: %d addr: %s",
priority_label->result[0].config_id, priority_label->result[0].action, printaddr(&a_tcp->addr, thread_seq));
MESA_handle_runtime_log(g_tsg_para.logger,
RLOG_LV_DEBUG,
"INTERCEPT",
"Hit intercept policy, policy_id: %d action: %d addr: %s",
priority_label->result[0].config_id,
(unsigned char)priority_label->result[0].action,
printaddr(&a_tcp->addr, thread_seq)
);
break;
case TSG_ACTION_NONE:
default:
@@ -394,6 +547,7 @@ extern "C" char TSG_MASTER_TCP_ENTRY(struct streaminfo *a_tcp, void **pme, int t
}
break;
case OP_STATE_DATA:
break;
case OP_STATE_CLOSE:
if(_context!=NULL)
{
@@ -403,8 +557,7 @@ extern "C" char TSG_MASTER_TCP_ENTRY(struct streaminfo *a_tcp, void **pme, int t
identify_info.proto=_context->proto;
master_send_log(a_tcp, _context->result, _context->hit_cnt, &identify_info, thread_seq);
dictator_free(thread_seq, (void *)_context->result);
_context->result=NULL;
free_context(pme, thread_seq);
}
}
default:
@@ -414,7 +567,72 @@ extern "C" char TSG_MASTER_TCP_ENTRY(struct streaminfo *a_tcp, void **pme, int t
return state;
}
extern "C" char TSG_MASTER_UDP_ENTRY(struct streaminfo *a_udp, void **pme, int thread_seq,void *a_packet)
{
int ret=0,opt_value=0;
scan_status_t mid=NULL;
int state=APP_STATE_DROPME;
Maat_rule_t *p_result=NULL;
Maat_rule_t result[MAX_RESULT_NUM];
struct _identify_info identify_info;
struct _master_context *_context=(struct _master_context *)*pme;
switch(a_udp->opstate)
{
case OP_STATE_PENDING:
memset(&identify_info, 0, sizeof(identify_info));
identify_application_protocol(a_udp, &identify_info);
ret=tsg_scan_nesting_addr(g_tsg_maat_feather, a_udp, identify_info.proto, &mid, result, MAX_RESULT_NUM);
p_result=tsg_policy_decision_criteria(result, ret);
if(p_result!=NULL)
{
switch((unsigned char)p_result->action)
{
case TSG_ACTION_DENY:
opt_value=1;
MESA_set_stream_opt(a_udp, MSO_DROP_STREAM, (void *)&opt_value, sizeof(opt_value));
state=PROT_STATE_DROPME|PROT_STATE_DROPPKT;
FS_operate(g_tsg_para.fs2_handle, g_tsg_para.fs2_field_id[TSG_FS2_DENY], 0, FS_OP_ADD, 1);
break;
case TSG_ACTION_BYPASS:
init_context(pme, identify_info.proto, p_result, thread_seq);
state=APP_STATE_GIVEME|APP_STATE_KILL_OTHER;
FS_operate(g_tsg_para.fs2_handle, g_tsg_para.fs2_field_id[TSG_FS2_BYPASS], 0, FS_OP_ADD, 1);
break;
case TSG_ACTION_MONITOR:
init_context(pme, identify_info.proto, p_result, thread_seq);
state=APP_STATE_GIVEME;
break;
case TSG_ACTION_INTERCEPT:
case TSG_ACTION_MANIPULATE:
default:
break;
}
}
break;
case OP_STATE_DATA:
break;
case OP_STATE_CLOSE:
if(_context!=NULL)
{
if(_context->hit_cnt>0 && _context->result!=NULL)
{
memset(&identify_info, 0, sizeof(identify_info));
identify_info.proto=_context->proto;
master_send_log(a_udp, _context->result, _context->hit_cnt, &identify_info, thread_seq);
free_context(pme, thread_seq);
}
}
break;
default:
break;
}
return state;
}
extern "C" int TSG_MASTER_INIT()
{
@@ -440,6 +658,7 @@ extern "C" int TSG_MASTER_INIT()
}
MESA_load_profile_int_def(tsg_conffile, "SYSTEM", "DEVICE_ID", &g_tsg_para.device_id, 0);
MESA_load_profile_short_def(tsg_conffile, "SYSTEM", "TIMEOUT", (short *)&g_tsg_para.timeout, 300);
MESA_load_profile_string_def(tsg_conffile, "SYSTEM", "POLICY_PRIORITY_LABEL", label_buff, sizeof(label_buff), "POLICY_PRIORITY");
g_tsg_para.priority_project_id=project_producer_register(label_buff, PROJECT_VAL_TYPE_STRUCT, free_policy_label);

View File

@@ -59,6 +59,7 @@ struct _master_context
#define _MAX_TABLE_NAME_LEN 64
typedef struct _tsg_para
{
unsigned short timeout;
int device_id;
int table_id[TABLE_MAX];
int dyn_subscribe_ip_table_id; //TSG_DYN_SUBSCRIBER_IP

View File

@@ -432,7 +432,7 @@ int tsg_scan_nesting_addr(Maat_feather_t maat_feather, const struct streaminfo *
maat_ret,
result[hit_num].config_id,
result[hit_num].service_id,
result[hit_num].action
(unsigned char)result[hit_num].action
);
hit_num+=maat_ret;
@@ -476,7 +476,7 @@ int tsg_scan_nesting_addr(Maat_feather_t maat_feather, const struct streaminfo *
maat_ret,
result[hit_num].config_id,
result[hit_num].service_id,
result[hit_num].action,
(unsigned char)result[hit_num].action,
printaddr(&a_stream->addr, a_stream->threadnum)
);
@@ -522,7 +522,7 @@ int tsg_scan_nesting_addr(Maat_feather_t maat_feather, const struct streaminfo *
maat_ret,
result[hit_num].config_id,
result[hit_num].service_id,
result[hit_num].action,
(unsigned char)result[hit_num].action,
printaddr(&a_stream->addr, a_stream->threadnum)
);
@@ -565,7 +565,7 @@ int tsg_scan_nesting_addr(Maat_feather_t maat_feather, const struct streaminfo *
maat_ret,
result[hit_num].config_id,
result[hit_num].service_id,
result[hit_num].action,
(unsigned char)result[hit_num].action,
printaddr(&a_stream->addr, a_stream->threadnum)
);

View File

@@ -19,7 +19,7 @@
#include "tsg_send_log.h"
#include "tsg_send_log_internal.h"
char TSG_SEND_LOG_VERSION_20191129=0;
char TSG_SEND_LOG_VERSION_20200119=0;
struct tsg_log_instance_t *g_tsg_log_instance;
@@ -238,7 +238,7 @@ int TLD_append_streaminfo(struct tsg_log_instance_t *instance, struct TLD_handle
return 0;
}
int load_log_common_field(const char *filename, id2field_t *id2field, id2field_t *service2topic)
int load_log_common_field(const char *filename, id2field_t *id2field, id2field_t **service2topic, int *max_service)
{
int i=0;
int ret=0,id=0;
@@ -246,6 +246,7 @@ int load_log_common_field(const char *filename, id2field_t *id2field, id2field_t
char line[1024]={0};
char field_name[64]={0};
char type_name[32]={0};
id2field_t *_service2topic=NULL;
fp=fopen(filename, "r");
if(fp==NULL)
@@ -282,9 +283,36 @@ int load_log_common_field(const char *filename, id2field_t *id2field, id2field_t
default:
if((strncasecmp("TOPIC", type_name, strlen("TOPIC")))==0)
{
service2topic[id].type = TLD_TYPE_MAX;
service2topic[id].id = id;
memcpy(service2topic[id].name, field_name, strlen(field_name));
if(_service2topic==NULL)
{
_service2topic=(id2field_t *)calloc(1, sizeof(id2field_t)*(id+1));
_service2topic[id].type = TLD_TYPE_MAX;
_service2topic[id].id = id;
memcpy(_service2topic[id].name, field_name, strlen(field_name));
*max_service=id+1;
}
else
{
if(*max_service<=id)
{
_service2topic=(id2field_t *)realloc(_service2topic, sizeof(id2field_t)*(id+1));
memset(&_service2topic[id], 0, sizeof(id2field_t));
_service2topic[id].type = TLD_TYPE_MAX;
_service2topic[id].id = id;
memcpy(_service2topic[id].name, field_name, strlen(field_name));
*max_service=id+1;
}
else
{
memset(&_service2topic[id], 0, sizeof(id2field_t));
_service2topic[id].type = TLD_TYPE_MAX;
_service2topic[id].id = id;
memcpy(_service2topic[id].name, field_name, strlen(field_name));
}
}
}
break;
}
@@ -296,6 +324,8 @@ int load_log_common_field(const char *filename, id2field_t *id2field, id2field_t
fclose(fp);
fp=NULL;
*service2topic=_service2topic;
return 0;
}
@@ -359,13 +389,11 @@ struct tsg_log_instance_t *tsg_sendlog_init(const char *conffile)
return NULL;
}
MESA_load_profile_int_def(conffile, "TSG_LOG", "MAX_SERVICE",&(_instance->max_service), 0);
//(_instance->topic_rkt)=(rd_kafka_topic_t **)calloc(1, sizeof(void *));
(_instance->topic_rkt)=(rd_kafka_topic_t **)calloc(1, (1+_instance->max_service)*sizeof(rd_kafka_topic_t*));
load_log_common_field(_instance->common_field_file, _instance->id2field, &(_instance->service2topic), &(_instance->max_service));
_instance->service2topic=(id2field_t *)calloc(1, (1+_instance->max_service)*sizeof(id2field_t));
load_log_common_field(_instance->common_field_file, _instance->id2field, _instance->service2topic);
if(_instance->service2topic!=NULL)
{
_instance->topic_rkt=(rd_kafka_topic_t **)calloc(1, (_instance->max_service)*sizeof(rd_kafka_topic_t*));
for(i=0; i<_instance->max_service+1; i++)
{
@@ -375,6 +403,11 @@ struct tsg_log_instance_t *tsg_sendlog_init(const char *conffile)
_instance->topic_rkt[_instance->service2topic[i].id]=rd_kafka_topic_new(kafka_handle, _instance->service2topic[i].name, topic_conf);
}
}
}
else
{
MESA_handle_runtime_log(_instance->logger, RLOG_LV_FATAL, "KAFKA_INIT", "load_log_common_field is error, please check %s", _instance->common_field_file);
}
return _instance;
}
@@ -382,7 +415,7 @@ struct tsg_log_instance_t *tsg_sendlog_init(const char *conffile)
int tsg_send_log(struct tsg_log_instance_t *instance, struct TLD_handle_t *handle, tsg_log_t *log_msg, int thread_id)
{
int i=0,ret=0,status=0;
int i=0,status=0;
char *payload=NULL;
struct TLD_handle_t *_handle=handle;
struct tsg_log_instance_t *_instance=instance;
@@ -401,36 +434,9 @@ int tsg_send_log(struct tsg_log_instance_t *instance, struct TLD_handle_t *handl
return 0;
}
//TODO
//common_user_tags
//common_isp
//common_app_label
//common_app_id
//common_protocol_id
//common_has_dup_traffic
//common_stream_error
TLD_append_streaminfo(instance, handle, log_msg->a_stream);
TLD_append(_handle, _instance->id2field[LOG_COMMON_SLED_IP].name, (void *)(_instance->local_ip_str), TLD_TYPE_STRING);
#if 0
struct vxlan_info vinfo;
int opt_val_len = sizeof(vinfo);
status=MESA_get_stream_opt(log_msg->a_stream, MSO_STREAM_VXLAN_INFO, &vinfo, &opt_val_len);
if(status < 0)
{
MESA_handle_runtime_log(_instance->logger, RLOG_LV_DEBUG, "TSG_SEND_LOG", "tsg log: get vxlan info error, tuple4: %s", printaddr(&log_msg->a_stream->addr, thread_id));
}
else
{
TLD_append((TLD_handle_t)_handle, _instance->id2field[LOG_COMMON_LINK_ID].name, (void *)(long)vinfo.link_id, TLD_TYPE_LONG);
TLD_append((TLD_handle_t)_handle, _instance->id2field[LOG_COMMON_DIRECTION].name, (void *)(long)vinfo.link_dir, TLD_TYPE_LONG);
TLD_append((TLD_handle_t)_handle, _instance->id2field[LOG_COMMON_DEVICE_ID].name, (void *)(long)vinfo.dev_id, TLD_TYPE_LONG);
TLD_append((TLD_handle_t)_handle, _instance->id2field[LOG_COMMON_ENTRANCE_ID].name, (void *)(long)vinfo.entrance_id, TLD_TYPE_LONG);
TLD_append((TLD_handle_t)_handle, _instance->id2field[LOG_COMMON_ENCAPSULATION].name, (void *)(long)vinfo.encap_type, TLD_TYPE_LONG);
}
#endif
for(i=0;i<log_msg->result_num; i++)
{
switch(log_msg->result[i].do_log)
@@ -457,33 +463,6 @@ int tsg_send_log(struct tsg_log_instance_t *instance, struct TLD_handle_t *handl
TLD_append(_handle, _instance->id2field[LOG_COMMON_SERVICE].name, (void *)(long)(log_msg->result[i].service_id), TLD_TYPE_LONG);
TLD_append(_handle, _instance->id2field[LOG_COMMON_ACTION].name, (void *)(long)((unsigned char)log_msg->result[i].action), TLD_TYPE_LONG);
if(log_msg->result[i].serv_def_len<128)
{
TLD_append(_handle, _instance->id2field[LOG_COMMON_USER_REGION].name, (void *)(log_msg->result[i].service_defined), TLD_TYPE_STRING);
}
else
{
char *service_defined=(char *)calloc(1, log_msg->result[i].serv_def_len+1);
ret=Maat_read_rule(g_tsg_maat_feather, &log_msg->result[i], MAAT_RULE_SERV_DEFINE, service_defined, log_msg->result[i].serv_def_len);
if(ret==log_msg->result[i].serv_def_len)
{
TLD_append(_handle, _instance->id2field[LOG_COMMON_USER_REGION].name, (void *)service_defined, TLD_TYPE_STRING);
}
else
{
MESA_handle_runtime_log(_instance->logger,
RLOG_LV_FATAL,
"TSG_SEND_LOG",
"Fetch service_defined failed, policy_id: %d service: %d action: %d addr: %s",
log_msg->result[i].config_id,
log_msg->result[i].service_id,
log_msg->result[i].action,
printaddr(&log_msg->a_stream->addr, thread_id));
}
free((void *)service_defined);
service_defined=NULL;
}
payload = cJSON_PrintUnformatted(_handle->object);
status = rd_kafka_produce(_instance->topic_rkt[log_msg->result[i].service_id], RD_KAFKA_PARTITION_UA, RD_KAFKA_MSG_F_COPY, payload, strlen(payload), NULL, 0, NULL);
@@ -506,7 +485,6 @@ int tsg_send_log(struct tsg_log_instance_t *instance, struct TLD_handle_t *handl
TLD_delete(_handle, _instance->id2field[LOG_COMMON_POLICY_ID].name);
TLD_delete(_handle, _instance->id2field[LOG_COMMON_SERVICE].name);
TLD_delete(_handle, _instance->id2field[LOG_COMMON_ACTION].name);
TLD_delete(_handle, _instance->id2field[LOG_COMMON_USER_REGION].name);
FS_operate(g_tsg_para.fs2_handle, g_tsg_para.fs2_field_id[TSG_FS2_LOG], 0, FS_OP_ADD, 1);
}

View File

@@ -4,6 +4,7 @@ global:
g_*;
*TSG_MASTER_INIT*;
*TSG_MASTER_TCP_ENTRY*;
*TSG_MASTER_UDP_ENTRY*;
*TSG_MASTER_UNLOAD*;
*tsg_scan_nesting_addr*;
*tsg_pull_policy_result*;