增加会话创建延迟时间的流标签

增加mail的协议识别
修正预编译安装脚本
This commit is contained in:
liuxueli
2020-03-23 11:41:04 +08:00
parent 23c0bff4c5
commit e122469706
4 changed files with 71 additions and 2 deletions

View File

@@ -9,6 +9,10 @@ if [[ -z `grep -rn 'POLICY_PRIORITY' ${DST}/etc/project_list.conf` ]];then
echo 'POLICY_PRIORITY struct' >> ${DST}/etc/project_list.conf
fi
if [[ -z `grep -rn 'ESTABLISH_LATENCY' ${DST}/etc/project_list.conf` ]];then
echo 'ESTABLISH_LATENCY long' >> ${DST}/etc/project_list.conf
fi
if [[ -z `grep -rn 'tsg_master.inf' ${DST}/plug/conflist.inf` ]];then
sed -i '/\[platform\]/a\./plug/platform/tsg_master/tsg_master.inf' ${DST}/plug/conflist.inf
fi

View File

@@ -3,3 +3,4 @@ DST=${RPM_INSTALL_PREFIX}
mkdir -p ${DST}/plug/platform/
sed -i '/tsg_master.inf/d' ${DST}/plug/conflist.inf
sed -i '/POLICY_PRIORITY/d' ${DST}/etc/project_list.conf
sed -i '/ESTABLISH_LATENCY/d' ${DST}/etc/project_list.conf

View File

@@ -2,10 +2,12 @@
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <sys/time.h>
#include <unistd.h>
#include <MESA/http.h>
#include <MESA/ftp.h>
#include <MESA/mail.h>
#include <MESA/stream.h>
#include <MESA/MESA_prof_load.h>
#include <MESA/MESA_handle_logger.h>
@@ -39,7 +41,7 @@ static __attribute__((__used__)) const char * GIT_VERSION_UNKNOWN = NULL;
#endif
char TSG_MASTER_VERSION_20200119=0;
char TSG_MASTER_VERSION_20200322=0;
const char *tsg_conffile="tsgconf/main.conf";
g_tsg_para_t g_tsg_para;
@@ -403,6 +405,13 @@ static int identify_application_protocol(struct streaminfo *a_stream, struct _id
//mail
ret=mail_protocol_identify(a_stream);
if(ret>=SMTP_PROTOCOL&& ret<=IMAP_PROTOCOL)
{
identify_info->proto=PROTO_MAIL;
return 1;
}
return ret;
}
@@ -425,6 +434,34 @@ extern "C" char TSG_MASTER_TCP_ENTRY(struct streaminfo *a_tcp, void **pme, int t
memset(&identify_info, 0, sizeof(identify_info));
identify_application_protocol(a_tcp, &identify_info);
if(identify_info.proto==PROTO_HTTP)
{
struct timeval tv;
long establish_latency_ms=0;
gettimeofday(&tv, NULL);
establish_latency_ms=(tv.tv_sec-a_tcp->ptcpdetail->createtime)*1000+tv.tv_usec/1000;
ret=project_req_add_long(a_tcp, g_tsg_para.establish_latency_project_id, establish_latency_ms);
if(ret<0)
{
MESA_handle_runtime_log(g_tsg_para.logger,
RLOG_LV_FATAL,
"PROJECT_ADD",
"Add policy_priority_label failed, establish latency ms: %llu addr: %s",
establish_latency_ms,
printaddr(&a_tcp->addr, thread_seq)
);
}
else
{
MESA_handle_runtime_log(g_tsg_para.logger,
RLOG_LV_DEBUG,
"PROJECT_ADD",
"Add policy_priority_label successfully, establish latency ms: %llu addr: %s",
establish_latency_ms,
printaddr(&a_tcp->addr, thread_seq)
);
}
}
ret=tsg_scan_nesting_addr(g_tsg_maat_feather, a_tcp, identify_info.proto, &mid, all_result+hit_num, MAX_RESULT_NUM-hit_num);
if(ret>0)
@@ -500,11 +537,23 @@ extern "C" char TSG_MASTER_TCP_ENTRY(struct streaminfo *a_tcp, void **pme, int t
if(q_result!=NULL && (p_result==q_result))
{
init_context(pme, identify_info.proto, p_result, thread_seq);
if(identify_info.proto>PROTO_UNKONWN && identify_info.proto<PROTO_MAX)
{
_context=(struct _master_context *)*pme;
memcpy(_context->domain, identify_info.domain, identify_info.domain_len);
_context->domain_len=identify_info.domain_len;
}
state=APP_STATE_GIVEME;
}
break;
case TSG_ACTION_BYPASS:
init_context(pme, identify_info.proto, p_result, thread_seq);
if(identify_info.proto>PROTO_UNKONWN && identify_info.proto<PROTO_MAX)
{
_context=(struct _master_context *)*pme;
memcpy(_context->domain, identify_info.domain, identify_info.domain_len);
_context->domain_len=identify_info.domain_len;
}
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;
@@ -563,7 +612,11 @@ extern "C" char TSG_MASTER_TCP_ENTRY(struct streaminfo *a_tcp, void **pme, int t
{
memset(&identify_info, 0, sizeof(identify_info));
identify_info.proto=_context->proto;
if(_context->domain_len>0)
{
memcpy(identify_info.domain, _context->domain, _context->domain_len);
identify_info.domain_len=_context->domain_len;
}
master_send_log(a_tcp, _context->result, _context->hit_cnt, &identify_info, thread_seq);
free_context(pme, thread_seq);
}
@@ -683,6 +736,14 @@ extern "C" int TSG_MASTER_INIT()
return -1;
}
MESA_load_profile_string_def(tsg_conffile, "SYSTEM", "ESTABLISH_LATENCY_LABEL", label_buff, sizeof(label_buff), "ESTABLISH_LATENCY");
g_tsg_para.establish_latency_project_id=project_producer_register(label_buff, PROJECT_VAL_TYPE_LONG, NULL);
if(g_tsg_para.establish_latency_project_id<0)
{
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_FATAL, "PROJECT_REGISTER", "Register %s failed ...", label_buff);
return -1;
}
ret=tsg_rule_init(tsg_conffile, g_tsg_para.logger);
if(ret<0)
{

View File

@@ -53,6 +53,8 @@ struct _master_context
{
tsg_protocol_t proto;
int hit_cnt;
int domain_len;
char domain[MAX_DOAMIN_LEN];
struct Maat_rule_t *result;
};
@@ -64,6 +66,7 @@ typedef struct _tsg_para
int table_id[TABLE_MAX];
int dyn_subscribe_ip_table_id; //TSG_DYN_SUBSCRIBER_IP
int priority_project_id;
int establish_latency_project_id;
int fs2_field_id[TSG_FS2_MAX];
char table_name[TABLE_MAX][_MAX_TABLE_NAME_LEN];
void *logger;