支持根据日志级别动态调用printaddr
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include <MESA/stream.h>
|
||||
#include <MESA/MESA_handle_logger.h>
|
||||
|
||||
#include "tsg_log.h"
|
||||
#include "tsg_stat.h"
|
||||
#include "tsg_rule.h"
|
||||
#include "app_label.h"
|
||||
@@ -546,14 +547,12 @@ static unsigned char do_action_reset(const struct streaminfo *a_stream, struct m
|
||||
int ret=MESA_rst_tcp((struct streaminfo *)a_stream, &rst_paras, sizeof(rst_paras));
|
||||
if(ret<0)
|
||||
{
|
||||
MESA_handle_runtime_log(g_tsg_para.logger,
|
||||
RLOG_LV_FATAL,
|
||||
"RST_TCP",
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_FATAL, LOG_MODULE_ACTION,
|
||||
"Send RST failed policy_id: %d service: %d action: %d addr: %s",
|
||||
p_result->rule_id,
|
||||
p_result->service_id,
|
||||
(unsigned char)p_result->action,
|
||||
PRINTADDR(a_stream, g_tsg_para.level)
|
||||
printaddr(&(a_stream->addr), a_stream->threadnum)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <MESA/MESA_prof_load.h>
|
||||
#include <MESA/MESA_handle_logger.h>
|
||||
|
||||
#include "tsg_log.h"
|
||||
#include "tsg_bridge.h"
|
||||
#include "tsg_variable.h"
|
||||
#include "tsg_sync_state.h"
|
||||
@@ -250,7 +251,7 @@ int session_async_bridge_set_data(const struct streaminfo *a_stream, int bridge_
|
||||
int ret=stream_bridge_async_data_put(a_stream, bridge_id, data);
|
||||
if(ret<0)
|
||||
{
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_FATAL, "BRIDGE", "Add project failed, bridge_id: %d addr: %s", bridge_id, PRINTADDR(a_stream, g_tsg_para.level));
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_FATAL, LOG_MODULE_BRIDGE, "Add project failed, bridge_id: %d addr: %s", bridge_id, printaddr(&(a_stream->addr), a_stream->threadnum));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1153,7 +1154,7 @@ int tsg_bridge_init(const char *conffile)
|
||||
g_tsg_bridge_para[i].id=stream_bridge_build(g_tsg_bridge_para[i].name, "w");
|
||||
if(g_tsg_bridge_para[i].id<0)
|
||||
{
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_FATAL, "INIT_BRIDGE", "stream_bridge_build is error, bridge_name: %s", g_tsg_bridge_para[i].name);
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_FATAL, LOG_MODULE_BRIDGE, "stream_bridge_build is error, bridge_name: %s", g_tsg_bridge_para[i].name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1161,8 +1162,8 @@ int tsg_bridge_init(const char *conffile)
|
||||
{
|
||||
int ret=stream_bridge_register_data_sync_cb(g_tsg_bridge_para[i].id, g_tsg_bridge_para[i].sync_cb);
|
||||
if(ret<0)
|
||||
{
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_FATAL, "BRIDGE_SYNC_CB", "Register callback failed, bridge_name: %d",g_tsg_bridge_para[i].name);
|
||||
{
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_FATAL, LOG_MODULE_BRIDGE, "Register callback failed, bridge_name: %d",g_tsg_bridge_para[i].name);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -1171,8 +1172,8 @@ int tsg_bridge_init(const char *conffile)
|
||||
{
|
||||
int ret=stream_bridge_register_data_free_cb(g_tsg_bridge_para[i].id, g_tsg_bridge_para[i].free_cb);
|
||||
if(ret<0)
|
||||
{
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_FATAL, "BRIDGE_FREE_CB", "Register async free callback failed, bridge_name: %d", g_tsg_bridge_para[i].name);
|
||||
{
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_FATAL, LOG_MODULE_BRIDGE, "Register async free callback failed, bridge_name: %d", g_tsg_bridge_para[i].name);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <MESA/MESA_handle_logger.h>
|
||||
#include <MESA/MESA_jump_layer.h>
|
||||
|
||||
#include "tsg_log.h"
|
||||
#include "tsg_stat.h"
|
||||
#include "app_label.h"
|
||||
#include "tsg_rule.h"
|
||||
@@ -1247,7 +1248,7 @@ int session_set_segment_id_in_activing(const struct streaminfo *a_stream, TSG_SE
|
||||
return 0;
|
||||
}
|
||||
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_INFO, "set_segment_id", "set in active status , service:%d, sid:%u,session addr:%s", service, segment_id, PRINTADDR(a_stream, g_tsg_para.level));
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_DEBUG, LOG_MODULE_SID, "set in active status , service:%d, sid:%u,session addr:%s", service, segment_id, printaddr(&(a_stream->addr), a_stream->threadnum));
|
||||
|
||||
struct segment_id_list sid_list;
|
||||
sid_list.sz_sidlist=1;
|
||||
@@ -1930,7 +1931,7 @@ int session_app_identify_result_cb(const struct streaminfo *a_stream, int bridge
|
||||
scan_app_num=1;
|
||||
break;
|
||||
default:
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_FATAL, "APP_BRIDGE_CB", "Unknown type: %d addr: %s", identify_result->origin, PRINTADDR(a_stream, g_tsg_para.level));
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_FATAL, LOG_MODULE_SYNC_APP, "Unknown type: %d addr: %s", identify_result->origin, printaddr(&(a_stream->addr), a_stream->threadnum));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2029,7 +2030,7 @@ size_t session_pending_state_deal(const struct streaminfo *a_stream, struct sess
|
||||
|
||||
if((is_only_monitor(matched_rules, matched_cnt)) && srt_process_context->proto==PROTO_DNS) // business deal action of monitor
|
||||
{
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_INFO, "pending_state_deal", "is_only_monitor, clean hit_num to 0, :%s", PRINTADDR(a_stream, g_tsg_para.level));
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_DEBUG, LOG_MODULE_PENDING, "is_only_monitor, clean hit_num to 0, :%s", printaddr(&(a_stream->addr), a_stream->threadnum));
|
||||
matched_cnt=0;
|
||||
}
|
||||
|
||||
@@ -2451,13 +2452,13 @@ extern "C" int TSG_MASTER_INIT()
|
||||
ret=tsg_get_sn(device_sn_filename, g_tsg_para.device_sn, sizeof(g_tsg_para.device_sn));
|
||||
if(ret==0)
|
||||
{
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_FATAL, "GET_DEVICE_SN", "Get device SN failed; please check :%s", device_sn_filename);
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_FATAL, LOG_MODULE_INIT, "Get device SN failed; please check :%s", device_sn_filename);
|
||||
}
|
||||
|
||||
ret=device_id_set_telegraf(g_tsg_para.device_sn);
|
||||
if(ret<0)
|
||||
{
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_FATAL, "SET_DEVICE_SN_TO_TELEGRAF", "Set device SN(%s) failed; please check :%s", g_tsg_para.device_sn, "/etc/default/telegraf");
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_FATAL, LOG_MODULE_INIT, "Set device SN(%s) failed; please check :%s", g_tsg_para.device_sn, "/etc/default/telegraf");
|
||||
}
|
||||
|
||||
ret=tsg_bridge_init(tsg_conffile);
|
||||
@@ -2473,14 +2474,14 @@ extern "C" int TSG_MASTER_INIT()
|
||||
ret=tsg_maat_rule_init(tsg_conffile);
|
||||
if(ret<0)
|
||||
{
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_FATAL, "INIT_MAAT", "tsg_maat_rule_init failed ...");
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_FATAL, LOG_MODULE_INIT, "tsg_maat_rule_init failed ...");
|
||||
return -1;
|
||||
}
|
||||
|
||||
g_tsg_log_instance=tsg_sendlog_init(tsg_conffile);
|
||||
if(g_tsg_log_instance==NULL)
|
||||
{
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_FATAL, "INIT_SENDLOG", "tsg_sendlog_init failed ...");
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_FATAL, LOG_MODULE_INIT, "tsg_sendlog_init failed ...");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -2489,8 +2490,7 @@ extern "C" int TSG_MASTER_INIT()
|
||||
|
||||
ret=tsg_metric_init(tsg_conffile, g_tsg_para.logger);
|
||||
if(ret<0)
|
||||
{
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_FATAL, "INIT_STATISTIC", "tsg_metric_init failed ...");
|
||||
{MASTER_LOG(g_tsg_para.logger, RLOG_LV_FATAL, LOG_MODULE_INIT, "tsg_metric_init failed ...");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -2499,7 +2499,7 @@ extern "C" int TSG_MASTER_INIT()
|
||||
ret=tsg_gtp_signaling_hash_init(tsg_conffile, g_tsg_para.logger);
|
||||
if(ret<0)
|
||||
{
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_FATAL, "INIT_GTP_HASH", "tsg_gtp_signaling_hash_init failed ...");
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_FATAL, LOG_MODULE_INIT, "tsg_gtp_signaling_hash_init failed ...");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <MESA/MESA_prof_load.h>
|
||||
#include <MESA/MESA_handle_logger.h>
|
||||
|
||||
#include "tsg_log.h"
|
||||
#include "tsg_rule_internal.h"
|
||||
#include "tsg_gtp_signaling.h"
|
||||
|
||||
@@ -241,7 +242,7 @@ int tsg_gtp_signaling_hash_init(const char* conffile, void *logger)
|
||||
g_gtp_signaling_hash_handle=MESA_htable_create(&args, sizeof(MESA_htable_create_args_t));
|
||||
if(g_gtp_signaling_hash_handle==NULL)
|
||||
{
|
||||
MESA_handle_runtime_log(logger, RLOG_LV_FATAL, "GTP_SIGNALING", "MESA_htable_create failed");
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_FATAL, LOG_MODULE_INIT, "GTP_SIGNALING MESA_htable_create failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -314,13 +314,12 @@ unsigned char send_icmp_unreachable(const struct streaminfo *a_stream)
|
||||
|
||||
if(a_stream==NULL)
|
||||
{
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_DEBUG, __FUNCTION__, "a_stream is NULL");
|
||||
MESA_set_stream_opt(a_stream, MSO_DROP_CURRENT_PKT, (void *)&opt_value, sizeof(opt_value));
|
||||
return STATE_GIVEME;
|
||||
}
|
||||
|
||||
get_rawpkt_ret = get_rawpkt_opt_from_streaminfo(a_stream, RAW_PKT_GET_DATA, &raw_pkt);
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_DEBUG, __FUNCTION__, "get_raw_opt_from_streaminfo() get_rawpkt_ret = %d", get_rawpkt_ret);
|
||||
|
||||
if(0==get_rawpkt_ret && NULL!=raw_pkt)
|
||||
{
|
||||
format_icmp((char *)raw_pkt+ETHERNET_BYTE_LEN, icmp_buf, &icmp_len, a_stream->addr.addrtype);
|
||||
|
||||
24
src/tsg_log.h
Normal file
24
src/tsg_log.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#define LOG_MODULE_ACTION "DO_ACTION"
|
||||
#define LOG_MODULE_BRIDGE "BRIDGE"
|
||||
#define LOG_MODULE_SID "SID"
|
||||
#define LOG_MODULE_SYNC_APP "SYN_APP"
|
||||
#define LOG_MODULE_PENDING "PENDING"
|
||||
#define LOG_MODULE_INIT "INIT"
|
||||
#define LOG_MODULE_PROXY "PROXY"
|
||||
#define LOG_MODULE_MAAT "MAAT"
|
||||
#define LOG_MODULE_SENDLOG "SENDLOG"
|
||||
#define LOG_MODULE_MPACK "MPACK"
|
||||
#define LOG_MODULE_METRICS "METRICS"
|
||||
|
||||
#define MASTER_LOG(handle, level, module, format, ...) \
|
||||
do \
|
||||
{ \
|
||||
if (MESA_handle_runtime_log_level_enabled(handle, level)) \
|
||||
{ \
|
||||
MESA_handle_runtime_log(handle, level, module, "file %s, line %d, " format, \
|
||||
__FILE__, __LINE__, ##__VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <MESA/stream.h>
|
||||
#include <MESA/MESA_handle_logger.h>
|
||||
|
||||
#include "tsg_log.h"
|
||||
#include "tsg_rule.h"
|
||||
#include "tsg_variable.h"
|
||||
#include "tsg_send_log.h"
|
||||
@@ -119,18 +120,21 @@ static char* tsg_proxy_ipv6_errmsg_get(enum tsg_proxy_ipv6hdr_parse_error _errno
|
||||
static void tsg_proxy_ip_header_parse(const void *a_packet, enum addr_type_t addr_type, const struct streaminfo *stream, struct pkt_info *pktinfo){
|
||||
if(addr_type == ADDR_TYPE_IPV6){
|
||||
int ret = tsg_proxy_ipv6_header_parse(a_packet, pktinfo);
|
||||
if(ret < 0){
|
||||
if(ret < 0)
|
||||
{
|
||||
pktinfo->parse_failed=1;
|
||||
char *errmsg = tsg_proxy_ipv6_errmsg_get((enum tsg_proxy_ipv6hdr_parse_error)ret);
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_FATAL, "PROXY", "Failed at parse ipv6 header, errmsg = %s, stream treaceid = %llu", errmsg, tsg_get_stream_trace_id(stream));
|
||||
pktinfo->parse_failed = 1;
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_FATAL, LOG_MODULE_PROXY, "Failed at parse ipv6 header, errmsg = %s, stream treaceid = %llu", errmsg, tsg_get_stream_trace_id(stream));
|
||||
}
|
||||
}
|
||||
else{
|
||||
else
|
||||
{
|
||||
int ret = tsg_proxy_ipv4_header_parse(a_packet, pktinfo);
|
||||
if(ret < 0){
|
||||
if(ret < 0)
|
||||
{
|
||||
pktinfo->parse_failed=1;
|
||||
char *errmsg = tsg_proxy_ipv4_errmsg_get((enum tsg_proxy_ipv4hdr_parse_error)ret);
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_FATAL, "PROXY", "Failed at parse ipv4 header, errmsg = %s, stream treaceid = %llu", errmsg, tsg_get_stream_trace_id(stream));
|
||||
pktinfo->parse_failed = 1;
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_FATAL, LOG_MODULE_PROXY, "Failed at parse ipv4 header, errmsg = %s, stream treaceid = %llu", errmsg, tsg_get_stream_trace_id(stream));
|
||||
}
|
||||
}
|
||||
return;
|
||||
@@ -206,105 +210,119 @@ static void tsg_proxy_tcpopt_get(struct tsg_proxy_tcp_option *tcp_opt, struct tc
|
||||
|
||||
static int tsg_proxy_rawpkt_info_get(const void *raw_pkt, struct tsg_proxy_tcp_option *tcp_opt, const struct streaminfo *stream)
|
||||
{
|
||||
int ret;
|
||||
struct segment_id_list *sids = NULL;
|
||||
int ret;
|
||||
struct segment_id_list *sids = NULL;
|
||||
|
||||
ret = get_rawpkt_opt_from_streaminfo(stream, RAW_PKT_GET_SID_LIST, &sids);
|
||||
if (ret != sizeof(struct segment_id_list)) {
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_INFO, "PROXY", "Failed to get sid list, stream treaceid = %llu, %s", tsg_get_stream_trace_id(stream), PRINTADDR(stream, g_tsg_para.level));
|
||||
return -1;
|
||||
}
|
||||
memcpy(&tcp_opt->sid_list, sids, sizeof(struct segment_id_list));
|
||||
ret = get_rawpkt_opt_from_streaminfo(stream, RAW_PKT_GET_SID_LIST, &sids);
|
||||
if (ret != sizeof(struct segment_id_list))
|
||||
{
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_DEBUG, LOG_MODULE_PROXY, "Failed to get sid list, stream treaceid = %llu, %s", tsg_get_stream_trace_id(stream), printaddr(&(stream->addr), stream->threadnum));
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(&tcp_opt->sid_list, sids, sizeof(struct segment_id_list));
|
||||
|
||||
void *route_ctx = NULL;
|
||||
ret = get_rawpkt_opt_from_streaminfo(stream, RAW_PKT_GET_ROUTE_CTX, &route_ctx);
|
||||
if (ret < 0) {
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_INFO, "PROXY", "Failed to get route ctx, stream treaceid = %llu, %s", tsg_get_stream_trace_id(stream), PRINTADDR(stream, g_tsg_para.level));
|
||||
return -1;
|
||||
}
|
||||
tcp_opt->route_ctx_len = ret;
|
||||
memcpy(tcp_opt->route_ctx, route_ctx, ret);
|
||||
void *route_ctx = NULL;
|
||||
ret = get_rawpkt_opt_from_streaminfo(stream, RAW_PKT_GET_ROUTE_CTX, &route_ctx);
|
||||
if (ret < 0)
|
||||
{
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_DEBUG, LOG_MODULE_PROXY, "Failed to get route ctx, stream treaceid = %llu, %s", tsg_get_stream_trace_id(stream), printaddr(&(stream->addr), stream->threadnum));
|
||||
return -1;
|
||||
}
|
||||
tcp_opt->route_ctx_len = ret;
|
||||
memcpy(tcp_opt->route_ctx, route_ctx, ret);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void tsg_proxy_tcp_parse(struct tsg_proxy_tcp_attribute *tcp_attr, struct pkt_info *pktinfo, const struct streaminfo *stream)
|
||||
{
|
||||
const void *raw_pkt = get_rawpkt_from_streaminfo(stream);
|
||||
const void *raw_pkt = get_rawpkt_from_streaminfo(stream);
|
||||
|
||||
if (!raw_pkt) {
|
||||
return;
|
||||
}
|
||||
if (!raw_pkt)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (pktinfo->tcphdr->syn && !pktinfo->tcphdr->ack) {
|
||||
tsg_proxy_rawpkt_info_get(raw_pkt, &tcp_attr->tcp_opt_client, stream);
|
||||
tsg_proxy_tcpopt_get(&tcp_attr->tcp_opt_client, pktinfo->tcphdr, pktinfo->tcphdr_len);
|
||||
}
|
||||
if (pktinfo->tcphdr->syn && !pktinfo->tcphdr->ack)
|
||||
{
|
||||
tsg_proxy_rawpkt_info_get(raw_pkt, &tcp_attr->tcp_opt_client, stream);
|
||||
tsg_proxy_tcpopt_get(&tcp_attr->tcp_opt_client, pktinfo->tcphdr, pktinfo->tcphdr_len);
|
||||
}
|
||||
|
||||
if (pktinfo->tcphdr->syn && pktinfo->tcphdr->ack) {
|
||||
tsg_proxy_rawpkt_info_get(raw_pkt, &tcp_attr->tcp_opt_server, stream);
|
||||
tsg_proxy_tcpopt_get(&tcp_attr->tcp_opt_server, pktinfo->tcphdr, pktinfo->tcphdr_len);
|
||||
}
|
||||
if (pktinfo->tcphdr->syn && pktinfo->tcphdr->ack)
|
||||
{
|
||||
tsg_proxy_rawpkt_info_get(raw_pkt, &tcp_attr->tcp_opt_server, stream);
|
||||
tsg_proxy_tcpopt_get(&tcp_attr->tcp_opt_server, pktinfo->tcphdr, pktinfo->tcphdr_len);
|
||||
}
|
||||
}
|
||||
|
||||
static struct tsg_proxy_tcp_attribute *tsg_proxy_tcp_attribute_get(const struct streaminfo *stream)
|
||||
{
|
||||
struct session_runtime_attribute *srt_attribute = (struct session_runtime_attribute *)session_runtime_attribute_new(stream);
|
||||
if (srt_attribute == NULL) {
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_FATAL, "PROXY", "Failed to get session runtime attribute, stream treaceid = %llu", tsg_get_stream_trace_id(stream));
|
||||
return NULL;
|
||||
}
|
||||
struct session_runtime_attribute *srt_attribute = (struct session_runtime_attribute *)session_runtime_attribute_new(stream);
|
||||
if (srt_attribute == NULL)
|
||||
{
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_FATAL, LOG_MODULE_PROXY, "Failed to get session runtime attribute, stream treaceid = %llu", tsg_get_stream_trace_id(stream));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (srt_attribute->proxy_tcp_attr == NULL) {
|
||||
srt_attribute->proxy_tcp_attr = (struct tsg_proxy_tcp_attribute *)dictator_malloc(stream->threadnum, sizeof(struct tsg_proxy_tcp_attribute));
|
||||
memset(srt_attribute->proxy_tcp_attr, 0, sizeof(struct tsg_proxy_tcp_attribute));
|
||||
}
|
||||
if (srt_attribute->proxy_tcp_attr == NULL)
|
||||
{
|
||||
srt_attribute->proxy_tcp_attr = (struct tsg_proxy_tcp_attribute *)dictator_malloc(stream->threadnum, sizeof(struct tsg_proxy_tcp_attribute));
|
||||
memset(srt_attribute->proxy_tcp_attr, 0, sizeof(struct tsg_proxy_tcp_attribute));
|
||||
}
|
||||
|
||||
return srt_attribute->proxy_tcp_attr;
|
||||
return srt_attribute->proxy_tcp_attr;
|
||||
}
|
||||
|
||||
void tsg_proxy_first_data_process(const struct streaminfo *stream, struct tsg_proxy_tcp_attribute *tcp_attr, struct pkt_info *pktinfo)
|
||||
{
|
||||
struct tsg_proxy_tcp_option tcp_opt;
|
||||
enum TSG_PROTOCOL tcp_protocol;
|
||||
const struct session_runtime_process_context *session_context = session_runtime_process_context_get(stream);
|
||||
struct tsg_proxy_tcp_option tcp_opt;
|
||||
enum TSG_PROTOCOL tcp_protocol;
|
||||
const struct session_runtime_process_context *session_context = session_runtime_process_context_get(stream);
|
||||
|
||||
memset(&tcp_opt, 0, sizeof(struct tsg_proxy_tcp_option));
|
||||
memset(&tcp_opt, 0, sizeof(struct tsg_proxy_tcp_option));
|
||||
tcp_protocol = srt_process_context_get_protocol(session_context);
|
||||
switch(tcp_protocol)
|
||||
switch(tcp_protocol)
|
||||
{
|
||||
case PROTO_SSL:
|
||||
tcp_attr->tcp_protocol = 0x1;
|
||||
break;
|
||||
|
||||
tcp_attr->tcp_protocol = 0x1;
|
||||
break;
|
||||
case PROTO_SSH:
|
||||
tcp_attr->tcp_protocol = 0x2;
|
||||
break;
|
||||
|
||||
tcp_attr->tcp_protocol = 0x2;
|
||||
break;
|
||||
default:
|
||||
tcp_attr->tcp_protocol = 0x0;
|
||||
|
||||
tcp_attr->tcp_protocol = 0x0;
|
||||
break;
|
||||
}
|
||||
|
||||
if(tcp_attr->tcp_opt_client.ts_set && tcp_attr->tcp_opt_server.ts_set) {
|
||||
tsg_proxy_tcpopt_get(&tcp_opt, pktinfo->tcphdr, pktinfo->tcphdr_len);
|
||||
if(stream->curdir == DIR_C2S){
|
||||
tcp_attr->tcp_opt_client.ts_val = tcp_opt.ts_val;
|
||||
tcp_attr->tcp_opt_server.ts_val = tcp_opt.ts_ecr;
|
||||
} else {
|
||||
tcp_attr->tcp_opt_client.ts_val = tcp_opt.ts_ecr;
|
||||
tcp_attr->tcp_opt_server.ts_val = tcp_opt.ts_val;
|
||||
}
|
||||
}
|
||||
if(tcp_attr->tcp_opt_client.ts_set && tcp_attr->tcp_opt_server.ts_set)
|
||||
{
|
||||
tsg_proxy_tcpopt_get(&tcp_opt, pktinfo->tcphdr, pktinfo->tcphdr_len);
|
||||
if(stream->curdir == DIR_C2S)
|
||||
{
|
||||
tcp_attr->tcp_opt_client.ts_val = tcp_opt.ts_val;
|
||||
tcp_attr->tcp_opt_server.ts_val = tcp_opt.ts_ecr;
|
||||
}
|
||||
else
|
||||
{
|
||||
tcp_attr->tcp_opt_client.ts_val = tcp_opt.ts_ecr;
|
||||
tcp_attr->tcp_opt_server.ts_val = tcp_opt.ts_val;
|
||||
}
|
||||
}
|
||||
|
||||
tcp_attr->tcp_info_packet_cur_dir = stream->curdir;
|
||||
if (stream->curdir == DIR_C2S) {
|
||||
tcp_attr->tcp_seq = pktinfo->tcphdr->seq;
|
||||
tcp_attr->tcp_ack = pktinfo->tcphdr->ack_seq;
|
||||
} else {
|
||||
tcp_attr->tcp_seq = pktinfo->tcphdr->ack_seq;
|
||||
tcp_attr->tcp_ack = pktinfo->tcphdr->seq;
|
||||
}
|
||||
tcp_attr->tcp_info_packet_cur_dir = stream->curdir;
|
||||
if (stream->curdir == DIR_C2S)
|
||||
{
|
||||
tcp_attr->tcp_seq = pktinfo->tcphdr->seq;
|
||||
tcp_attr->tcp_ack = pktinfo->tcphdr->ack_seq;
|
||||
}
|
||||
else
|
||||
{
|
||||
tcp_attr->tcp_seq = pktinfo->tcphdr->ack_seq;
|
||||
tcp_attr->tcp_ack = pktinfo->tcphdr->seq;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -319,28 +337,32 @@ void tsg_proxy_tcp_options_parse(const struct streaminfo *stream, const void *a_
|
||||
struct tsg_proxy_tcp_attribute *tcp_attr = tsg_proxy_tcp_attribute_get(stream);
|
||||
|
||||
|
||||
if (tcp_attr == NULL) {
|
||||
if(tcp_attr == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (tcp_attr->first_data_pkt_processed) {
|
||||
return;
|
||||
}
|
||||
if(tcp_attr->first_data_pkt_processed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
memset(&pktinfo, 0, sizeof(struct pkt_info));
|
||||
tsg_proxy_ip_header_parse(a_packet, (enum addr_type_t)stream->addr.addrtype, stream, &pktinfo);
|
||||
if (pktinfo.parse_failed) {
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_FATAL, "PROXY", "invalid ip header, bypass pkt");
|
||||
if (pktinfo.parse_failed)
|
||||
{
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_FATAL, LOG_MODULE_PROXY, "invalid ip header, bypass pkt");
|
||||
return;
|
||||
}
|
||||
|
||||
if(stream->ptcpdetail->datalen > 0) {
|
||||
tsg_proxy_first_data_process(stream, tcp_attr, &pktinfo);
|
||||
tcp_attr->first_data_pkt_processed = 1;
|
||||
return;
|
||||
}
|
||||
if(stream->ptcpdetail->datalen > 0)
|
||||
{
|
||||
tsg_proxy_first_data_process(stream, tcp_attr, &pktinfo);
|
||||
tcp_attr->first_data_pkt_processed = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
tsg_proxy_tcp_parse(tcp_attr, &pktinfo, stream);
|
||||
tsg_proxy_tcp_parse(tcp_attr, &pktinfo, stream);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -485,22 +507,22 @@ static void tsg_proxy_cmsg_s2c_rpkt_header(const struct streaminfo *stream, stru
|
||||
|
||||
static void tsg_proxy_tcp_attribute_dump(tsg_proxy_tcp_attribute *tcp_attr, struct proxy_cmsg *cmsg, const struct streaminfo *stream)
|
||||
{
|
||||
struct tsg_proxy_tcp_option *client = &tcp_attr->tcp_opt_client;
|
||||
struct tsg_proxy_tcp_option *server = &tcp_attr->tcp_opt_server;
|
||||
char client_sids_str[128] = {0};
|
||||
char server_sids_str[128] = {0};
|
||||
char temp[10] = {0};
|
||||
struct tsg_proxy_tcp_option *client = &tcp_attr->tcp_opt_client;
|
||||
struct tsg_proxy_tcp_option *server = &tcp_attr->tcp_opt_server;
|
||||
char client_sids_str[128] = {0};
|
||||
char server_sids_str[128] = {0};
|
||||
char temp[10] = {0};
|
||||
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_DEBUG, "PROXY", "dump tcp attribute for stream %s, session_id %llu",
|
||||
printaddr(&stream->addr, stream->threadnum), tsg_get_stream_trace_id(stream));
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_DEBUG, LOG_MODULE_PROXY, "dump tcp attribute for stream %s, session_id %llu", printaddr(&(stream->addr), stream->threadnum), tsg_get_stream_trace_id(stream));
|
||||
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_DEBUG, "PROXY", "tcp_seq %u, tcp_ack %u, tcp_protocol %u, tcp_info_packet_cur_dir %u\n"\
|
||||
"client mss %u, client wscale_set %u, client wscale %u, client sack %u, client ts_set %u, client ts_val %u, client window %u"\
|
||||
"server mss %u, server wscale_set %u, server wscale %u, server sack %u, server ts_set %u, server ts_val %u, server window %u",
|
||||
tcp_attr->tcp_seq, tcp_attr->tcp_ack, tcp_attr->tcp_protocol, tcp_attr->tcp_info_packet_cur_dir,
|
||||
client->mss, client->wscale_set, client->wscale, client->sack, client->ts_set, client->ts_val, client->window,
|
||||
server->mss, server->wscale_set, server->wscale, server->sack, server->ts_set, server->ts_val, server->window);
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_DEBUG, "PROXY", "tcp_seq_route_ctx len %u, tcp_ack_route_ctx len %u\n", client->route_ctx_len, server->route_ctx_len);
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_DEBUG, LOG_MODULE_PROXY, "tcp_seq %u, tcp_ack %u, tcp_protocol %u, tcp_info_packet_cur_dir %u\n"\
|
||||
"client mss %u, client wscale_set %u, client wscale %u, client sack %u, client ts_set %u, client ts_val %u, client window %u"\
|
||||
"server mss %u, server wscale_set %u, server wscale %u, server sack %u, server ts_set %u, server ts_val %u, server window %u",
|
||||
tcp_attr->tcp_seq, tcp_attr->tcp_ack, tcp_attr->tcp_protocol, tcp_attr->tcp_info_packet_cur_dir,
|
||||
client->mss, client->wscale_set, client->wscale, client->sack, client->ts_set, client->ts_val, client->window,
|
||||
server->mss, server->wscale_set, server->wscale, server->sack, server->ts_set, server->ts_val, server->window);
|
||||
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_DEBUG, LOG_MODULE_PROXY, "tcp_seq_route_ctx len %u, tcp_ack_route_ctx len %u\n", client->route_ctx_len, server->route_ctx_len);
|
||||
|
||||
for (unsigned int i = 0; i < client->sid_list.sz_sidlist; i++) {
|
||||
snprintf(temp, sizeof(temp), "%u", client->sid_list.sid_list[i]);
|
||||
@@ -512,10 +534,10 @@ static void tsg_proxy_tcp_attribute_dump(tsg_proxy_tcp_attribute *tcp_attr, stru
|
||||
strcat(server_sids_str, temp);
|
||||
strcat(server_sids_str, ",");
|
||||
}
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_DEBUG, "PROXY", "tcp_seq_sids num %u, tcp_seq_sids value: %s, tcp_ack_sids num %u, tcp_seq_sids value: %s",
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_DEBUG, LOG_MODULE_PROXY, "tcp_seq_sids num %u, tcp_seq_sids value: %s, tcp_ack_sids num %u, tcp_seq_sids value: %s",
|
||||
client->sid_list.sz_sidlist, client_sids_str, server->sid_list.sz_sidlist, server_sids_str);
|
||||
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_DEBUG, "proxy", "client subscribe id: %s\n"\
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_DEBUG, LOG_MODULE_PROXY, "client subscribe id: %s\n"\
|
||||
"server subscribe id: %s\n"\
|
||||
"client asn: %s\n"\
|
||||
"server asn: %s\n"\
|
||||
|
||||
104
src/tsg_rule.cpp
104
src/tsg_rule.cpp
@@ -5,6 +5,7 @@
|
||||
#include <time.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "tsg_log.h"
|
||||
#include "tsg_stat.h"
|
||||
#include "MESA/http.h"
|
||||
#include "MESA/cJSON.h"
|
||||
@@ -1815,7 +1816,7 @@ int init_scan_table(struct maat *feather, const char *conffile)
|
||||
g_tsg_maat_rt_para.scan_tb[i].id=maat_get_table_id(feather, g_tsg_maat_rt_para.scan_tb[i].name);
|
||||
if(g_tsg_maat_rt_para.scan_tb[i].id<0)
|
||||
{
|
||||
MESA_handle_runtime_log(g_tsg_maat_rt_para.logger, RLOG_LV_FATAL, "maat_table_get_id failed, table_name: %s", g_tsg_maat_rt_para.scan_tb[i].name);
|
||||
MASTER_LOG(g_tsg_maat_rt_para.logger, RLOG_LV_FATAL, LOG_MODULE_MAAT, "maat_table_get_id failed, table_name: %s", g_tsg_maat_rt_para.scan_tb[i].name);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -2257,27 +2258,23 @@ size_t tsg_scan_integer(const struct streaminfo *a_stream, struct maat *feather,
|
||||
int is_hited=maat_scan_integer(feather, g_tsg_maat_rt_para.scan_tb[idx].id, s_integer, rules, MAX_RESULT_NUM, &n_rules, s_mid);
|
||||
if(is_hited==MAAT_SCAN_HIT)
|
||||
{
|
||||
MESA_handle_runtime_log(g_tsg_maat_rt_para.logger,
|
||||
RLOG_LV_DEBUG,
|
||||
"SCAN_INTEGER",
|
||||
"Hit: %lld: scan ret: %d table_name: %s addr: %s, mid: %p",
|
||||
MASTER_LOG(g_tsg_maat_rt_para.logger, RLOG_LV_DEBUG, LOG_MODULE_MAAT,
|
||||
"SCAN_INTEGER Hit: %lld: scan ret: %d table_name: %s addr: %s, mid: %p",
|
||||
s_integer,
|
||||
is_hited,
|
||||
g_tsg_maat_rt_para.scan_tb[idx].name,
|
||||
PRINTADDR(a_stream, g_tsg_maat_rt_para.level),
|
||||
printaddr(&(a_stream->addr), a_stream->threadnum),
|
||||
s_mid
|
||||
);
|
||||
return matche_rules_convert(feather, rules, n_rules, matched_rules, n_matched_rules);
|
||||
}
|
||||
|
||||
MESA_handle_runtime_log(g_tsg_maat_rt_para.logger,
|
||||
RLOG_LV_DEBUG,
|
||||
"SCAN_INTEGER",
|
||||
"No hit: %lld: scan ret: %d table_name: %s addr: %s, mid: %p",
|
||||
MASTER_LOG(g_tsg_maat_rt_para.logger, RLOG_LV_DEBUG, LOG_MODULE_MAAT,
|
||||
"SCAN_INTEGER No hit: %lld: scan ret: %d table_name: %s addr: %s, mid: %p",
|
||||
s_integer,
|
||||
is_hited,
|
||||
g_tsg_maat_rt_para.scan_tb[idx].name,
|
||||
PRINTADDR(a_stream, g_tsg_maat_rt_para.level),
|
||||
printaddr(&(a_stream->addr), a_stream->threadnum),
|
||||
s_mid
|
||||
);
|
||||
return 0;
|
||||
@@ -2290,27 +2287,23 @@ size_t tsg_scan_flags(const struct streaminfo *a_stream, struct maat *feather, u
|
||||
int is_hited=maat_scan_flag(feather, g_tsg_maat_rt_para.scan_tb[idx].id, flags, rules, MAX_RESULT_NUM, &n_rules, s_mid);
|
||||
if(is_hited==MAAT_SCAN_HIT)
|
||||
{
|
||||
MESA_handle_runtime_log(g_tsg_maat_rt_para.logger,
|
||||
RLOG_LV_DEBUG,
|
||||
"SCAN_FLAGS",
|
||||
"Hit: %llu scan ret: %d table_name: %s addr: %s, mid: %p",
|
||||
MASTER_LOG(g_tsg_maat_rt_para.logger, RLOG_LV_DEBUG, LOG_MODULE_MAAT,
|
||||
"SCAN_FLAGS Hit: %llu scan ret: %d table_name: %s addr: %s, mid: %p",
|
||||
flags,
|
||||
is_hited,
|
||||
g_tsg_maat_rt_para.scan_tb[idx].name,
|
||||
PRINTADDR(a_stream, g_tsg_maat_rt_para.level),
|
||||
printaddr(&(a_stream->addr), a_stream->threadnum),
|
||||
s_mid
|
||||
);
|
||||
return matche_rules_convert(feather, rules, n_rules, matched_rules, n_matched_rules);
|
||||
}
|
||||
|
||||
MESA_handle_runtime_log(g_tsg_maat_rt_para.logger,
|
||||
RLOG_LV_DEBUG,
|
||||
"SCAN_FLAGS",
|
||||
"No hit: %llu scan ret: %d table_name: %s addr: %s, mid: %p",
|
||||
MASTER_LOG(g_tsg_maat_rt_para.logger, RLOG_LV_DEBUG, LOG_MODULE_MAAT,
|
||||
"SCAN_FLAGS No hit: %llu scan ret: %d table_name: %s addr: %s, mid: %p",
|
||||
flags,
|
||||
is_hited,
|
||||
g_tsg_maat_rt_para.scan_tb[idx].name,
|
||||
PRINTADDR(a_stream, g_tsg_maat_rt_para.level),
|
||||
printaddr(&(a_stream->addr), a_stream->threadnum),
|
||||
s_mid
|
||||
);
|
||||
return 0;
|
||||
@@ -2323,28 +2316,24 @@ size_t tsg_scan_string(const struct streaminfo *a_stream, struct maat *feather,
|
||||
int is_hited=maat_scan_string(feather, g_tsg_maat_rt_para.scan_tb[idx].id, s_data, s_data_len, rules, MAX_RESULT_NUM, &n_rules, s_mid);
|
||||
if(is_hited==MAAT_SCAN_HIT)
|
||||
{
|
||||
MESA_handle_runtime_log(g_tsg_maat_rt_para.logger,
|
||||
RLOG_LV_DEBUG,
|
||||
"SCAN_STRING",
|
||||
"Hit: %s len: %lu scan ret: %d table_name: %s addr: %s, mid: %p",
|
||||
MASTER_LOG(g_tsg_maat_rt_para.logger, RLOG_LV_DEBUG, LOG_MODULE_MAAT,
|
||||
"SCAN_STRING Hit: %s len: %lu scan ret: %d table_name: %s addr: %s, mid: %p",
|
||||
s_data,
|
||||
s_data_len,
|
||||
is_hited,
|
||||
g_tsg_maat_rt_para.scan_tb[idx].name,
|
||||
PRINTADDR(a_stream, g_tsg_maat_rt_para.level),
|
||||
printaddr(&(a_stream->addr), a_stream->threadnum),
|
||||
s_mid);
|
||||
return matche_rules_convert(feather, rules, n_rules, matched_rules, n_matched_rules);
|
||||
}
|
||||
|
||||
MESA_handle_runtime_log(g_tsg_maat_rt_para.logger,
|
||||
RLOG_LV_DEBUG,
|
||||
"SCAN_STRING",
|
||||
"No hit: %s len: %lu scan ret: %d table_name: %s addr: %s, mid: %p",
|
||||
MASTER_LOG(g_tsg_maat_rt_para.logger, RLOG_LV_DEBUG, LOG_MODULE_MAAT,
|
||||
"SCAN_STRING No hit: %s len: %lu scan ret: %d table_name: %s addr: %s, mid: %p",
|
||||
s_data,
|
||||
s_data_len,
|
||||
is_hited,
|
||||
g_tsg_maat_rt_para.scan_tb[idx].name,
|
||||
PRINTADDR(a_stream, g_tsg_maat_rt_para.level),
|
||||
printaddr(&(a_stream->addr), a_stream->threadnum),
|
||||
s_mid
|
||||
);
|
||||
return 0;
|
||||
@@ -2391,24 +2380,20 @@ size_t tsg_scan_ipv4_address(const struct streaminfo *a_stream, struct maat *fea
|
||||
|
||||
if(n_matched_rules>0)
|
||||
{
|
||||
MESA_handle_runtime_log(g_tsg_maat_rt_para.logger,
|
||||
RLOG_LV_DEBUG,
|
||||
"SCAN_IPV4",
|
||||
"Hit %s addr: %s return n_rules: %llu, mid: %p",
|
||||
MASTER_LOG(g_tsg_maat_rt_para.logger, RLOG_LV_DEBUG, LOG_MODULE_MAAT,
|
||||
"SCAN_IPV4 Hit %s addr: %s return n_rules: %llu, mid: %p",
|
||||
g_tsg_maat_rt_para.scan_tb[idx].name,
|
||||
PRINTADDR(a_stream, g_tsg_maat_rt_para.level),
|
||||
printaddr(&(a_stream->addr), a_stream->threadnum),
|
||||
n_matched_rules,
|
||||
s_mid
|
||||
);
|
||||
return matche_rules_convert(feather, matched_rules, n_matched_rules, rules, n_rules);
|
||||
}
|
||||
|
||||
MESA_handle_runtime_log(g_tsg_maat_rt_para.logger,
|
||||
RLOG_LV_DEBUG,
|
||||
"SCAN_IPV4",
|
||||
"Not hit %s addr: %s Scan return: %d, mid: %p",
|
||||
MASTER_LOG(g_tsg_maat_rt_para.logger, RLOG_LV_DEBUG, LOG_MODULE_MAAT,
|
||||
"SCAN_IPV4 Not hit %s addr: %s Scan return: %d, mid: %p",
|
||||
g_tsg_maat_rt_para.scan_tb[idx].name,
|
||||
PRINTADDR(a_stream, g_tsg_maat_rt_para.level),
|
||||
printaddr(&(a_stream->addr), a_stream->threadnum),
|
||||
is_hited,
|
||||
s_mid
|
||||
);
|
||||
@@ -2457,24 +2442,20 @@ size_t tsg_scan_ipv6_address(const struct streaminfo *a_stream, struct maat *fea
|
||||
|
||||
if(n_matched_rules>0)
|
||||
{
|
||||
MESA_handle_runtime_log(g_tsg_maat_rt_para.logger,
|
||||
RLOG_LV_DEBUG,
|
||||
"SCAN_IPV6",
|
||||
"Hit %s addr: %s return n_rules: %llu, mid: %p",
|
||||
MASTER_LOG(g_tsg_maat_rt_para.logger, RLOG_LV_DEBUG, LOG_MODULE_MAAT,
|
||||
"SCAN_IPV6 Hit %s addr: %s return n_rules: %llu, mid: %p",
|
||||
g_tsg_maat_rt_para.scan_tb[idx].name,
|
||||
PRINTADDR(a_stream, g_tsg_maat_rt_para.level),
|
||||
printaddr(&(a_stream->addr), a_stream->threadnum),
|
||||
n_matched_rules,
|
||||
s_mid
|
||||
);
|
||||
return matche_rules_convert(feather, matched_rules, n_matched_rules, rules, n_rules);
|
||||
}
|
||||
|
||||
MESA_handle_runtime_log(g_tsg_maat_rt_para.logger,
|
||||
RLOG_LV_DEBUG,
|
||||
"SCAN_IPV6",
|
||||
"Not hit %s addr: %s Scan return: %d, mid: %p",
|
||||
MASTER_LOG(g_tsg_maat_rt_para.logger, RLOG_LV_DEBUG, LOG_MODULE_MAAT,
|
||||
"SCAN_IPV6 Not hit %s addr: %s Scan return: %d, mid: %p",
|
||||
g_tsg_maat_rt_para.scan_tb[idx].name,
|
||||
PRINTADDR(a_stream, g_tsg_maat_rt_para.level),
|
||||
printaddr(&(a_stream->addr), a_stream->threadnum),
|
||||
is_hited,
|
||||
s_mid
|
||||
);
|
||||
@@ -2533,10 +2514,8 @@ int tsg_scan_intercept_exclusion(const struct streaminfo *a_stream, struct maat
|
||||
|
||||
if(ret>0)
|
||||
{
|
||||
MESA_handle_runtime_log(g_tsg_maat_rt_para.logger,
|
||||
RLOG_LV_DEBUG,
|
||||
"EXCLUSION_SSL_SNI",
|
||||
"Hit %s policy_id: %d service: %d action: %d Decryption Exclusion: [ policy_id: %d service: %d action: %d ] addr: %s",
|
||||
MASTER_LOG(g_tsg_maat_rt_para.logger, RLOG_LV_DEBUG, LOG_MODULE_MAAT,
|
||||
"EXCLUSION_SSL_SNI Hit %s policy_id: %d service: %d action: %d Decryption Exclusion: [ policy_id: %d service: %d action: %d ] addr: %s",
|
||||
domain,
|
||||
tmp_result.rule_id,
|
||||
tmp_result.service_id,
|
||||
@@ -2544,19 +2523,17 @@ int tsg_scan_intercept_exclusion(const struct streaminfo *a_stream, struct maat
|
||||
p_result->rule_id,
|
||||
p_result->service_id,
|
||||
(unsigned char)p_result->action,
|
||||
PRINTADDR(a_stream, g_tsg_maat_rt_para.level)
|
||||
printaddr(&(a_stream->addr), a_stream->threadnum)
|
||||
);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
MESA_handle_runtime_log(g_tsg_maat_rt_para.logger,
|
||||
RLOG_LV_DEBUG,
|
||||
"EXCLUSION_SSL_SNI",
|
||||
"Not hit %s stream_dir: %d addr: %s scan ret: %d",
|
||||
MASTER_LOG(g_tsg_maat_rt_para.logger, RLOG_LV_DEBUG, LOG_MODULE_MAAT,
|
||||
"EXCLUSION_SSL_SNI Not hit %s stream_dir: %d addr: %s scan ret: %d",
|
||||
domain,
|
||||
a_stream->dir,
|
||||
PRINTADDR(a_stream, g_tsg_maat_rt_para.level),
|
||||
printaddr(&(a_stream->addr), a_stream->threadnum),
|
||||
ret
|
||||
);
|
||||
|
||||
@@ -2598,7 +2575,8 @@ static int get_one_endpoint_ids(const struct streaminfo *a_stream, struct maat *
|
||||
}
|
||||
|
||||
id_array[offset++]=all_endpoint[i]->id;
|
||||
MESA_handle_runtime_log(g_tsg_maat_rt_para.logger, RLOG_LV_DEBUG, "endpoint", "addr: %s Get endpoint id: %d", PRINTADDR(a_stream, g_tsg_maat_rt_para.level), all_endpoint[i]->id);
|
||||
|
||||
MASTER_LOG(g_tsg_maat_rt_para.logger, RLOG_LV_DEBUG, LOG_MODULE_MAAT, "addr: %s Get endpoint id: %d", printaddr(&(a_stream->addr), a_stream->threadnum), all_endpoint[i]->id);
|
||||
|
||||
if(free_flag==1)
|
||||
{
|
||||
@@ -2827,7 +2805,7 @@ size_t tsg_scan_nesting_addr(const struct streaminfo *a_stream, struct maat *fea
|
||||
|
||||
if(matched_rules==NULL || n_matched_rules==0 || a_stream==NULL || feather==NULL)
|
||||
{
|
||||
MESA_handle_runtime_log(g_tsg_maat_rt_para.logger, RLOG_LV_DEBUG, "SCAN_NESTING_ADDR", "result==NULL || result_num<=0 || maat_feather==NULL || a_stream==NULL");
|
||||
MASTER_LOG(g_tsg_maat_rt_para.logger, RLOG_LV_DEBUG, LOG_MODULE_MAAT, "SCAN_NESTING_ADDR result==NULL || result_num<=0 || maat_feather==NULL || a_stream==NULL");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <MESA/MESA_prof_load.h>
|
||||
#include <MESA/MESA_handle_logger.h>
|
||||
|
||||
#include "tsg_log.h"
|
||||
#include "tsg_stat.h"
|
||||
#include "app_label.h"
|
||||
#include "tsg_entry.h"
|
||||
@@ -1643,17 +1644,17 @@ int set_intercept_info(struct tsg_log_instance_t *_instance, struct TLD_handle_t
|
||||
|
||||
int TLD_append_streaminfo(struct tsg_log_instance_t *instance, struct TLD_handle_t *handle, const struct streaminfo *a_stream)
|
||||
{
|
||||
if(instance==NULL || handle==NULL || a_stream==NULL)
|
||||
struct TLD_handle_t *_handle=handle;
|
||||
struct tsg_log_instance_t *_instance=instance;
|
||||
|
||||
if(_instance==NULL || _handle==NULL || a_stream==NULL)
|
||||
{
|
||||
if(instance)
|
||||
if(_instance)
|
||||
{
|
||||
MESA_handle_runtime_log(instance->logger, RLOG_LV_DEBUG, "TLD_APPEND_STREAM", "TLD_handle==NULL || addr==NULL");
|
||||
MASTER_LOG(_instance->logger, RLOG_LV_DEBUG, LOG_MODULE_SENDLOG, "TLD_APPEND_STREAM TLD_handle==NULL || addr==NULL");
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct TLD_handle_t *_handle=handle;
|
||||
struct tsg_log_instance_t *_instance=instance;
|
||||
|
||||
int ret=set_linkinfo(_instance, _handle, a_stream);
|
||||
if(ret==0)
|
||||
@@ -1884,7 +1885,7 @@ struct tsg_log_instance_t *tsg_sendlog_init(const char *conffile)
|
||||
MESA_load_profile_int_def(conffile, "TSG_LOG", "MODE",&(_instance->mode), 0);
|
||||
if(_instance->mode==CLOSE)
|
||||
{
|
||||
MESA_handle_runtime_log(_instance->logger, RLOG_LV_FATAL, "TSG_LOG", "Disable tsg_send_log");
|
||||
MASTER_LOG(_instance->logger, RLOG_LV_FATAL, LOG_MODULE_SENDLOG, "Disable tsg_send_log");
|
||||
return _instance;
|
||||
}
|
||||
|
||||
@@ -1906,9 +1907,7 @@ struct tsg_log_instance_t *tsg_sendlog_init(const char *conffile)
|
||||
_instance->udp_flow_project_id=project_customer_register(_instance->udp_label, "struct");
|
||||
if(_instance->tcp_flow_project_id<0 || _instance->udp_flow_project_id<0)
|
||||
{
|
||||
MESA_handle_runtime_log(_instance->logger,
|
||||
RLOG_LV_FATAL,
|
||||
"TCP_OR_UDP_LABEL",
|
||||
MASTER_LOG(_instance->logger, RLOG_LV_FATAL, LOG_MODULE_SENDLOG,
|
||||
"project_customer_register is error, tcp_label: %s udp_label: %s, please check etc/project.conf",
|
||||
_instance->tcp_label,
|
||||
_instance->udp_label
|
||||
@@ -1924,10 +1923,8 @@ struct tsg_log_instance_t *tsg_sendlog_init(const char *conffile)
|
||||
int ret=MESA_get_dev_ipv4(nic_name, (int *)&local_ip_nr);
|
||||
if(ret<0)
|
||||
{
|
||||
MESA_handle_runtime_log(_instance->logger,
|
||||
RLOG_LV_FATAL,
|
||||
"GET_LOCAL_IP",
|
||||
"MESA_get_dev_ipv4 is error, nic_name: %s, please check tsgconf/main.conf",
|
||||
MASTER_LOG(_instance->logger, RLOG_LV_FATAL, LOG_MODULE_SENDLOG,
|
||||
"GET_LOCAL_IP MESA_get_dev_ipv4 is error, nic_name: %s, please check tsgconf/main.conf",
|
||||
nic_name
|
||||
);
|
||||
return NULL;
|
||||
@@ -1956,7 +1953,7 @@ struct tsg_log_instance_t *tsg_sendlog_init(const char *conffile)
|
||||
|
||||
if(!(_instance->kafka_handle=rd_kafka_new(RD_KAFKA_PRODUCER, rdkafka_conf, kafka_errstr, sizeof(kafka_errstr))))
|
||||
{
|
||||
MESA_handle_runtime_log(_instance->logger, RLOG_LV_FATAL, "KAFKA_INIT", "rd_kafka_new is error");
|
||||
MASTER_LOG(_instance->logger, RLOG_LV_FATAL, LOG_MODULE_SENDLOG, "KAFKA_INIT rd_kafka_new is error");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1975,7 +1972,7 @@ struct tsg_log_instance_t *tsg_sendlog_init(const char *conffile)
|
||||
}
|
||||
else
|
||||
{
|
||||
MESA_handle_runtime_log(_instance->logger, RLOG_LV_FATAL, "KAFKA_INIT", "log_common_fields_new is error, please check %s", common_field_file);
|
||||
MASTER_LOG(_instance->logger, RLOG_LV_FATAL, LOG_MODULE_SENDLOG, "KAFKA_INIT log_common_fields_new is error, please check %s", common_field_file);
|
||||
}
|
||||
|
||||
return _instance;
|
||||
@@ -2035,12 +2032,11 @@ int send_log_by_type(struct tsg_log_instance_t *_instance, struct TLD_handle_t *
|
||||
int ret=update_percent(_instance, log_type, LOG_STATUS_DROP, thread_id);
|
||||
if(ret==1)
|
||||
{
|
||||
MESA_handle_runtime_log(_instance->logger, RLOG_LV_DEBUG,
|
||||
"record_log",
|
||||
MASTER_LOG(_instance->logger, RLOG_LV_DEBUG, LOG_MODULE_SENDLOG,
|
||||
"drop log: log_type=%d send_log_percent: %d addr=%s",
|
||||
log_type,
|
||||
_instance->service2topic[log_type].send_log_percent[thread_id],
|
||||
(a_stream==NULL ? "" : PRINTADDR(a_stream,_instance->level))
|
||||
(a_stream==NULL ? "" : printaddr(&(a_stream->addr), thread_id))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2062,12 +2058,11 @@ int send_event_log(struct tsg_log_instance_t *_instance, struct TLD_handle_t *_h
|
||||
{
|
||||
if(is_multi_hit_same_policy(&(rules[i]), policy_id, &repeat_cnt))
|
||||
{
|
||||
MESA_handle_runtime_log(_instance->logger, RLOG_LV_DEBUG,
|
||||
"tsg_send_log",
|
||||
MASTER_LOG(_instance->logger, RLOG_LV_DEBUG, LOG_MODULE_SENDLOG,
|
||||
"tsg same log:cfg_id=%d service=%d addr=%s",
|
||||
rules[i].rule_id,
|
||||
rules[i].service_id,
|
||||
(a_stream==NULL ? "" : PRINTADDR(a_stream,_instance->level))
|
||||
(a_stream==NULL ? "" : printaddr(&(a_stream->addr), thread_id))
|
||||
);
|
||||
continue;
|
||||
}
|
||||
@@ -2080,12 +2075,11 @@ int send_event_log(struct tsg_log_instance_t *_instance, struct TLD_handle_t *_h
|
||||
switch(rules[i].do_log)
|
||||
{
|
||||
case LOG_ABORT:
|
||||
MESA_handle_runtime_log(_instance->logger, RLOG_LV_DEBUG,
|
||||
"tsg_send_log",
|
||||
MASTER_LOG(_instance->logger, RLOG_LV_DEBUG, LOG_MODULE_SENDLOG,
|
||||
"tsg abort log:cfg_id=%d service=%d addr=%s",
|
||||
rules[i].rule_id,
|
||||
rules[i].service_id,
|
||||
(a_stream==NULL ? "" : PRINTADDR(a_stream,_instance->level))
|
||||
(a_stream==NULL ? "" : printaddr(&(a_stream->addr), thread_id))
|
||||
);
|
||||
|
||||
fs3_rule_stat_update(RULE_STAT_ABORT, (int)rules[i].action, 1);
|
||||
@@ -2155,36 +2149,36 @@ int deal_event_rules(struct tsg_log_instance_t *_instance, struct TLD_handle_t *
|
||||
|
||||
int tsg_send_log(struct tsg_log_instance_t *instance, struct TLD_handle_t *handle, const struct streaminfo *a_stream, enum LOG_TYPE log_type, struct maat_rule *rules, size_t n_rules, int thread_id)
|
||||
{
|
||||
if(instance==NULL || handle==NULL || rules==NULL || n_rules==0)
|
||||
struct TLD_handle_t *_handle=handle;
|
||||
struct tsg_log_instance_t *_instance=instance;
|
||||
|
||||
if(_instance==NULL || _handle==NULL || rules==NULL || n_rules==0)
|
||||
{
|
||||
TLD_cancel(handle);
|
||||
if(instance!=NULL)
|
||||
TLD_cancel(_handle);
|
||||
if(_instance!=NULL)
|
||||
{
|
||||
MESA_handle_runtime_log(instance->logger, RLOG_LV_DEBUG, "tsg_send_log", " instance==NULL || TLD_handle==NULL || log_msg==NULL ");
|
||||
MASTER_LOG(_instance->logger, RLOG_LV_DEBUG, LOG_MODULE_SENDLOG, " instance==NULL || TLD_handle==NULL || log_msg==NULL ");
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct TLD_handle_t *_handle=handle;
|
||||
struct tsg_log_instance_t *_instance=instance;
|
||||
|
||||
if(_instance->mode==CLOSE)
|
||||
{
|
||||
TLD_cancel(handle);
|
||||
TLD_cancel(_handle);
|
||||
tsg_stat_sendlog_update(_instance->sum_stat_row_id, LOG_STATUS_DROP, 1);
|
||||
tsg_stat_sendlog_update(_instance->sum_stat_row_id, LOG_STATUS_DROP_S, 1);
|
||||
MESA_handle_runtime_log(_instance->logger, RLOG_LV_INFO, "tsg_send_log", "Disable tsg_send_log.");
|
||||
MASTER_LOG(_instance->logger, RLOG_LV_INFO, LOG_MODULE_SENDLOG, "Disable tsg_send_log.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(is_hitted_shunt(a_stream))
|
||||
{
|
||||
TLD_cancel(handle);
|
||||
TLD_cancel(_handle);
|
||||
fs3_rule_stat_update(RULE_STAT_ABORT, TSG_ACTION_SHUNT, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
TLD_append_streaminfo(instance, handle, a_stream);
|
||||
TLD_append_streaminfo(_instance, _handle, a_stream);
|
||||
TLD_append(_handle, _instance->id2field[LOG_COMMON_SLED_IP].name, (void *)(_instance->local_ip_str), TLD_TYPE_STRING);
|
||||
if(strlen(g_tsg_para.device_sn)>0)
|
||||
{
|
||||
@@ -2275,9 +2269,7 @@ int tsg_send_payload(struct tsg_log_instance_t *instance, int topic_id, char *pa
|
||||
|
||||
if(payload==NULL || payload_len<=0 || topic_id<0 || _instance->service2topic[topic_id].topic_rkt==NULL)
|
||||
{
|
||||
MESA_handle_runtime_log(_instance->logger,
|
||||
RLOG_LV_INFO,
|
||||
"tsg_send_log",
|
||||
MASTER_LOG(_instance->logger, RLOG_LV_INFO, LOG_MODULE_SENDLOG,
|
||||
"tsg_send_log to kafka is error (payload==NULL || payload_len<=0 || topic_id<0 || _instance->service2topic[topic_id].topic_rkt==NULL), topic: %s",
|
||||
_instance->service2topic[topic_id].name
|
||||
);
|
||||
@@ -2289,9 +2281,7 @@ int tsg_send_payload(struct tsg_log_instance_t *instance, int topic_id, char *pa
|
||||
{
|
||||
update_percent(_instance, topic_id, LOG_STATUS_FAIL, thread_id);
|
||||
|
||||
MESA_handle_runtime_log(_instance->logger,
|
||||
RLOG_LV_INFO,
|
||||
"tsg_send_log",
|
||||
MASTER_LOG(_instance->logger, RLOG_LV_INFO, LOG_MODULE_SENDLOG,
|
||||
"tsg_send_log to kafka is error of code: %d %s(%s), status: %d, topic: %s %s",
|
||||
rd_kafka_last_error(),
|
||||
rd_kafka_err2name(rd_kafka_last_error()),
|
||||
@@ -2305,13 +2295,7 @@ int tsg_send_payload(struct tsg_log_instance_t *instance, int topic_id, char *pa
|
||||
else
|
||||
{
|
||||
update_percent(_instance, topic_id, LOG_STATUS_SUCCESS, thread_id);
|
||||
MESA_handle_runtime_log(_instance->logger,
|
||||
RLOG_LV_DEBUG,
|
||||
"tsg_send_log",
|
||||
"log send successfully %s: %s",
|
||||
_instance->service2topic[topic_id].name,
|
||||
payload
|
||||
);
|
||||
MASTER_LOG(_instance->logger, RLOG_LV_INFO, LOG_MODULE_SENDLOG, "log send successfully %s: %s", _instance->service2topic[topic_id].name, payload);
|
||||
}
|
||||
|
||||
update_percent(_instance, topic_id, LOG_STATUS_MAX, thread_id);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <MESA/MESA_prof_load.h>
|
||||
#include <MESA/MESA_handle_logger.h>
|
||||
|
||||
#include "tsg_log.h"
|
||||
#include "tsg_entry.h"
|
||||
#include "tsg_send_log.h"
|
||||
#include "tsg_statistic.h"
|
||||
@@ -279,21 +280,21 @@ int tsg_security_metric_init(const char *conffile, void *logger)
|
||||
MESA_load_profile_int_def(conffile, "SECURITY_HITS", "CYCLE", &g_tsg_statis_para.metric_cycle, 1000);
|
||||
if(g_tsg_statis_para.metric_cycle<=0)
|
||||
{
|
||||
MESA_handle_runtime_log(logger, RLOG_LV_FATAL, "SECURITY_HITS", "g_tsg_statis_para.metric_cycle error");
|
||||
return -1;
|
||||
MASTER_LOG(logger, RLOG_LV_FATAL, LOG_MODULE_METRICS, "SECURITY_HITS g_tsg_statis_para.metric_cycle error");
|
||||
return -1;
|
||||
}
|
||||
|
||||
g_tsg_statis_para.security_metric_handle = fieldstat_dynamic_instance_new(app_name, thread_num);
|
||||
if (g_tsg_statis_para.security_metric_handle == NULL)
|
||||
{
|
||||
MESA_handle_runtime_log(logger, RLOG_LV_FATAL, "SECURITY_HITS", "g_tsg_statis_para.security_metric_handle error");
|
||||
return -1;
|
||||
MASTER_LOG(logger, RLOG_LV_FATAL, LOG_MODULE_METRICS, "SECURITY_HITS g_tsg_statis_para.security_metric_handle error");
|
||||
return -1;
|
||||
}
|
||||
|
||||
fieldstat_dynamic_set_output_interval(g_tsg_statis_para.security_metric_handle, g_tsg_statis_para.metric_cycle);
|
||||
if (fs_server_port > 0 && strlen(fs_server_ip) > 0)
|
||||
{
|
||||
fieldstat_dynamic_set_line_protocol_server(g_tsg_statis_para.security_metric_handle, fs_server_ip, fs_server_port);
|
||||
fieldstat_dynamic_set_line_protocol_server(g_tsg_statis_para.security_metric_handle, fs_server_ip, fs_server_port);
|
||||
}
|
||||
|
||||
enum field_type security_metric_type[COLUMN_MAX] = {FIELD_TYPE_COUNTER};
|
||||
@@ -301,8 +302,8 @@ int tsg_security_metric_init(const char *conffile, void *logger)
|
||||
g_tsg_statis_para.metric_table_id = fieldstat_register_dynamic_table(g_tsg_statis_para.security_metric_handle, "security_rule_hits", security_metric_field, security_metric_type, (size_t)COLUMN_MAX, g_tsg_statis_para.security_column_ids);
|
||||
if(g_tsg_statis_para.metric_table_id<0)
|
||||
{
|
||||
MESA_handle_runtime_log(logger, RLOG_LV_FATAL, "SECURITY_HITS", "g_tsg_statis_para.metric_table_id error");
|
||||
return -1;
|
||||
MASTER_LOG(logger, RLOG_LV_FATAL, LOG_MODULE_METRICS, "SECURITY_HITS g_tsg_statis_para.metric_table_id error");
|
||||
return -1;
|
||||
}
|
||||
|
||||
fieldstat_dynamic_instance_start(g_tsg_statis_para.security_metric_handle);
|
||||
@@ -329,21 +330,21 @@ int tsg_traffic_metric_init(const char *conffile, void *logger)
|
||||
|
||||
if (g_tsg_statis_para.app_metric_cycle <= 0)
|
||||
{
|
||||
MESA_handle_runtime_log(logger, RLOG_LV_FATAL, "APP_METRIC", "g_tsg_statis_para.app_metric_cycle error");
|
||||
MASTER_LOG(logger, RLOG_LV_FATAL, LOG_MODULE_METRICS, "APP_METRIC g_tsg_statis_para.app_metric_cycle error");
|
||||
return -1;
|
||||
}
|
||||
|
||||
g_tsg_statis_para.app_metric_handle = fieldstat_dynamic_instance_new(app_name, thread_num);
|
||||
if (g_tsg_statis_para.app_metric_handle == NULL)
|
||||
if(g_tsg_statis_para.app_metric_handle == NULL)
|
||||
{
|
||||
MESA_handle_runtime_log(logger, RLOG_LV_FATAL, "APP_METRIC", "g_tsg_statis_para.app_metric_handle error");
|
||||
return -1;
|
||||
MASTER_LOG(logger, RLOG_LV_FATAL, LOG_MODULE_METRICS, "APP_METRIC g_tsg_statis_para.app_metric_handle error");
|
||||
return -1;
|
||||
}
|
||||
|
||||
fieldstat_dynamic_set_output_interval(g_tsg_statis_para.app_metric_handle, g_tsg_statis_para.app_metric_cycle);
|
||||
if (fs_server_port > 0 && strlen(fs_server_ip) > 0)
|
||||
{
|
||||
fieldstat_dynamic_set_line_protocol_server(g_tsg_statis_para.app_metric_handle, fs_server_ip, fs_server_port);
|
||||
fieldstat_dynamic_set_line_protocol_server(g_tsg_statis_para.app_metric_handle, fs_server_ip, fs_server_port);
|
||||
}
|
||||
|
||||
enum field_type app_metric_type[TRAFFIC_APP_MAX] = {FIELD_TYPE_COUNTER};
|
||||
@@ -353,8 +354,8 @@ int tsg_traffic_metric_init(const char *conffile, void *logger)
|
||||
g_tsg_statis_para.app_metric_table_id = fieldstat_register_dynamic_table(g_tsg_statis_para.app_metric_handle, "traffic_application_protocol_stat", app_metric_field, app_metric_type, (size_t)TRAFFIC_APP_MAX, g_tsg_statis_para.app_column_ids);
|
||||
if (g_tsg_statis_para.app_metric_table_id < 0)
|
||||
{
|
||||
MESA_handle_runtime_log(logger, RLOG_LV_FATAL, "APP_METRIC", "g_tsg_statis_para.app_metric_table_id error");
|
||||
return -1;
|
||||
MASTER_LOG(logger, RLOG_LV_FATAL, LOG_MODULE_METRICS, "APP_METRIC g_tsg_statis_para.app_metric_table_id error");
|
||||
return -1;
|
||||
}
|
||||
|
||||
fieldstat_dynamic_instance_start(g_tsg_statis_para.app_metric_handle);
|
||||
@@ -373,8 +374,8 @@ int tsg_metric_init(const char *conffile, void *logger)
|
||||
MESA_load_profile_int_def(conffile, "STATISTIC", "CYCLE", &g_tsg_statis_para.cycle, 1);
|
||||
if(g_tsg_statis_para.cycle<=0)
|
||||
{
|
||||
MESA_handle_runtime_log(logger, RLOG_LV_FATAL, "STATISTIC", "Disabale traffic statistic");
|
||||
return 0;
|
||||
MASTER_LOG(logger, RLOG_LV_FATAL, LOG_MODULE_METRICS, "Disabale traffic statistic");
|
||||
return 0;
|
||||
}
|
||||
|
||||
MESA_load_profile_short_nodef(conffile, "STATISTIC", "TELEGRAF_PORT", (short *)&(fs_server_port));
|
||||
@@ -393,7 +394,7 @@ int tsg_metric_init(const char *conffile, void *logger)
|
||||
|
||||
if (fs_server_port > 0 && strlen(fs_server_ip) > 0)
|
||||
{
|
||||
fieldstat_set_line_protocol_server(g_tsg_statis_para.statistic_handle, fs_server_ip, fs_server_port);
|
||||
fieldstat_set_line_protocol_server(g_tsg_statis_para.statistic_handle, fs_server_ip, fs_server_port);
|
||||
}
|
||||
|
||||
const char *static_column_name[STATIS_MAX] = {"sessions", "active_sessions", "closed_sessions", "in_bytes", "out_bytes", "in_pkts", "out_pkts", "asymmetric_c2s_flows", "asymmetric_s2c_flows"};
|
||||
@@ -409,15 +410,15 @@ int tsg_metric_init(const char *conffile, void *logger)
|
||||
int ret = tsg_security_metric_init(conffile, logger);
|
||||
if(ret<0)
|
||||
{
|
||||
MESA_handle_runtime_log(logger, RLOG_LV_FATAL, "INIT_METRIC", "tsg_security_metric_init failed ...");
|
||||
return -1;
|
||||
MASTER_LOG(logger, RLOG_LV_FATAL, LOG_MODULE_METRICS, "tsg_security_metric_init failed ...");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = tsg_traffic_metric_init(conffile, logger);
|
||||
if (ret < 0)
|
||||
{
|
||||
MESA_handle_runtime_log(logger, RLOG_LV_FATAL, "INIT_METRIC", "tsg_traffic_metric_init failed ...");
|
||||
return -1;
|
||||
MASTER_LOG(logger, RLOG_LV_FATAL, LOG_MODULE_METRICS, "tsg_traffic_metric_init failed ...");
|
||||
return -1;
|
||||
}
|
||||
|
||||
pthread_create(&g_tsg_statis_para.stat_thread_id, NULL, tsg_statistic_thread, NULL);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <MESA/cJSON.h>
|
||||
#include <MESA/MESA_handle_logger.h>
|
||||
|
||||
#include "tsg_log.h"
|
||||
#include "tsg_stat.h"
|
||||
#include "tsg_variable.h"
|
||||
#include "tsg_sync_state.h"
|
||||
@@ -36,15 +37,15 @@ static int mpack_send_pkt(const struct streaminfo *a_stream, mpack_writer_t *wri
|
||||
mpack_complete_map(writer); // mpack_init_map
|
||||
if (mpack_writer_destroy(writer) != mpack_ok)
|
||||
{
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_FATAL, "MPACK_WRITER", "An error occurred encoding the data!");
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_FATAL, LOG_MODULE_MPACK, "MPACK_WRITER An error occurred encoding the data!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_DEBUG, "MSGPACK_BUFF", "send buff_len = %lu, state: %u", *mpack_size, (uint8_t)a_stream->opstate);
|
||||
ret = sapp_inject_ctrl_pkt((struct streaminfo *)a_stream, SIO_DEFAULT, *mpack_data, *mpack_size, a_stream->routedir);
|
||||
if (ret == -1)
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_DEBUG, LOG_MODULE_MPACK, "MSGPACK_BUFF send buff_len = %lu, state: %u", *mpack_size, (uint8_t)a_stream->opstate);
|
||||
ret=sapp_inject_ctrl_pkt((struct streaminfo *)a_stream, SIO_DEFAULT, *mpack_data, *mpack_size, a_stream->routedir);
|
||||
if (ret==-1)
|
||||
{
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_DEBUG, "MSGPACK_BUFF_SEND", "An error occurred injecting the data! addr: %s", PRINTADDR(a_stream, g_tsg_para.level));
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_DEBUG, LOG_MODULE_MPACK, "MSGPACK_BUFF_SEND An error occurred injecting the data! addr: %s", printaddr(&(a_stream->addr), a_stream->threadnum));
|
||||
}
|
||||
|
||||
free(*mpack_data);
|
||||
@@ -166,7 +167,7 @@ static void mpack_append_cmsg_value(mpack_writer_t *writer, struct proxy_cmsg *c
|
||||
if (cmsg == NULL)
|
||||
{
|
||||
mpack_write_nil(writer);
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_DEBUG, "MSGPACK_PROXY", "No cmsg!");
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_DEBUG, LOG_MODULE_MPACK, "MSGPACK_PROXY no cmsg!");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -433,7 +434,7 @@ int mpack_parse_sce_profile_ids(const struct streaminfo *a_stream, mpack_tree_t
|
||||
mpack_node_t sf_profile_ids = mpack_node_map_cstr(sce_node, "sf_profile_ids");
|
||||
if (mpack_node_type(sf_profile_ids) != mpack_type_array || mpack_node_array_length(sf_profile_ids) == 0)
|
||||
{
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_INFO, "PARSE_SCE", "sf_profile_ids error! mpack_node_type(sf_profile_ids): %d, n_sf_profile_ids = 0", (int)mpack_node_type(sf_profile_ids));
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_INFO, LOG_MODULE_MPACK, "PARSE_SCE sf_profile_ids error! mpack_node_type(sf_profile_ids): %d, n_sf_profile_ids = 0", (int)mpack_node_type(sf_profile_ids));
|
||||
mpack_tree_destroy(&tree);
|
||||
return -1;
|
||||
}
|
||||
@@ -447,7 +448,7 @@ int mpack_parse_sce_profile_ids(const struct streaminfo *a_stream, mpack_tree_t
|
||||
}
|
||||
mpack_parse_append_profile_id(sf_profile_ids, sce_handle->profile_ids, &sce_handle->n_profile_ids, SCE_PROFILE_IDS);
|
||||
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_DEBUG, "PARSE_SCE", "n_profile_ids: %lu", sce_handle->n_profile_ids);
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_DEBUG, LOG_MODULE_MPACK, "PARSE_SCE n_profile_ids: %lu", sce_handle->n_profile_ids);
|
||||
mpack_tree_destroy(&tree);
|
||||
return 0;
|
||||
}
|
||||
@@ -457,7 +458,7 @@ int mpack_parse_shaper_profile_ids(const struct streaminfo *a_stream, mpack_tree
|
||||
size_t n_shaper_rule = mpack_node_array_length(shaper_node);
|
||||
if (n_shaper_rule == 0)
|
||||
{
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_INFO, "PARSE_SHAPER", "n_sh_profile_ids: 0");
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_INFO, LOG_MODULE_MPACK, "PARSE_SHAPER n_sh_profile_ids: 0");
|
||||
mpack_tree_destroy(&tree);
|
||||
return -1;
|
||||
}
|
||||
@@ -480,7 +481,7 @@ int mpack_parse_shaper_profile_ids(const struct streaminfo *a_stream, mpack_tree
|
||||
mpack_parse_append_profile_id(mpack_node_map_cstr(sh_ids_node, "profile_ids"), shaper_handle->shaper_rules[i].profile_ids, &shaper_handle->shaper_rules[i].n_profile_ids, SHAPR_PROFILE_IDS);
|
||||
}
|
||||
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_DEBUG, "PARSE_SHAPER", "n_sh_profile_ids: %lu;", shaper_handle->n_shaper_rule);
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_DEBUG, LOG_MODULE_MPACK, "PARSE_SHAPER n_sh_profile_ids: %lu;", shaper_handle->n_shaper_rule);
|
||||
mpack_tree_destroy(&tree);
|
||||
return 0;
|
||||
}
|
||||
@@ -490,7 +491,7 @@ int mpack_parse_proxy_intercept_info(const struct streaminfo *a_stream, mpack_tr
|
||||
mpack_node_t ssl_intercept_info = mpack_node_map_str_optional(proxy_node, "ssl_intercept_info", 18);
|
||||
if (mpack_node_type(ssl_intercept_info) != mpack_type_array)
|
||||
{
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_INFO, "PARSE_PROXY", "ssl_intercept_info error! mpack_node_type(ssl_intercept_info): %d", (int)mpack_node_type(ssl_intercept_info));
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_INFO, LOG_MODULE_MPACK, "PARSE_PROXY ssl_intercept_info error! mpack_node_type(ssl_intercept_info): %d", (int)mpack_node_type(ssl_intercept_info));
|
||||
mpack_tree_destroy(&tree);
|
||||
return -1;
|
||||
}
|
||||
@@ -504,9 +505,8 @@ int mpack_parse_proxy_intercept_info(const struct streaminfo *a_stream, mpack_tr
|
||||
}
|
||||
mpack_parse_intercept_info(ssl_intercept_info, proxy_handle, a_stream->threadnum);
|
||||
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_DEBUG,
|
||||
"PARSE_PROXY",
|
||||
"ssl_intercept_state: %u; ssl_upstream_latency: %llu; ssl_downstream_latency: %llu; ssl_upstream_version: %s; ssl_downstream_version: %s; ssl_pinning_state: %u; ssl_cert_verify: %u; ssl_error: %s; ssl_passthrough_reason: %s;",
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_DEBUG, LOG_MODULE_MPACK,
|
||||
"PARSE_PROXY ssl_intercept_state: %u; ssl_upstream_latency: %llu; ssl_downstream_latency: %llu; ssl_upstream_version: %s; ssl_downstream_version: %s; ssl_pinning_state: %u; ssl_cert_verify: %u; ssl_error: %s; ssl_passthrough_reason: %s;",
|
||||
proxy_handle->ssl_intercept_state,
|
||||
proxy_handle->ssl_upstream_latency,
|
||||
proxy_handle->ssl_downstream_latency,
|
||||
@@ -536,7 +536,7 @@ int tsg_parse_log_update_payload(const struct streaminfo *a_stream, const void *
|
||||
|
||||
if (mpack_node_type(root) == mpack_type_nil)
|
||||
{
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_INFO, "PARSE_LOG_UPDATE", "mpack_tree_parse error! payload_len = %u", payload_len);
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_INFO, LOG_MODULE_MPACK, "PARSE_LOG_UPDATE mpack_tree_parse error! payload_len = %u", payload_len);
|
||||
mpack_tree_destroy(&tree);
|
||||
tsg_stat_ctrl_service_updating_update(STAT_STATUS_FAIL, CTRL_SERVICE_UNKNOWN, 1);
|
||||
return -1;
|
||||
@@ -545,7 +545,7 @@ int tsg_parse_log_update_payload(const struct streaminfo *a_stream, const void *
|
||||
mpack_node_t method = mpack_node_map_cstr(root, "method");
|
||||
if (mpack_node_type(method) != mpack_type_str)
|
||||
{
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_INFO, "PARSE_LOG_UPDATE", "method error! mpack_node_type(method) = %d", (int)mpack_node_type(method));
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_INFO, LOG_MODULE_MPACK, "PARSE_LOG_UPDATE method error! mpack_node_type(method) = %d", (int)mpack_node_type(method));
|
||||
mpack_tree_destroy(&tree);
|
||||
tsg_stat_ctrl_service_updating_update(STAT_STATUS_FAIL, CTRL_SERVICE_UNKNOWN, 1);
|
||||
return -1;
|
||||
@@ -554,7 +554,7 @@ int tsg_parse_log_update_payload(const struct streaminfo *a_stream, const void *
|
||||
if (mpack_node_strlen(method) != strlen("log_update") || memcmp("log_update", mpack_node_str(method), strlen("log_update")) != 0)
|
||||
{
|
||||
// mpack_node_str(method) is contiguous memory
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_INFO, "PARSE_LOG_UPDATE", "method error! mpack_node_strlen(method) = %lu", mpack_node_strlen(method));
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_INFO, LOG_MODULE_MPACK, "PARSE_LOG_UPDATE method error! mpack_node_strlen(method) = %lu", mpack_node_strlen(method));
|
||||
mpack_tree_destroy(&tree);
|
||||
tsg_stat_ctrl_service_updating_update(STAT_STATUS_FAIL, CTRL_SERVICE_UNKNOWN, 1);
|
||||
return -1;
|
||||
@@ -564,7 +564,7 @@ int tsg_parse_log_update_payload(const struct streaminfo *a_stream, const void *
|
||||
if (session_id != tsg_get_stream_trace_id(a_stream))
|
||||
{
|
||||
// if session_id = 0, it's could be mpack_node_type(root) = nil
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_INFO, "PARSE_LOG_UPDATE", "session_id error! session_id: %llu, real session_id: %llu", session_id, tsg_get_stream_trace_id(a_stream));
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_INFO, LOG_MODULE_MPACK, "PARSE_LOG_UPDATE session_id error! session_id: %llu, real session_id: %llu", session_id, tsg_get_stream_trace_id(a_stream));
|
||||
mpack_tree_destroy(&tree);
|
||||
tsg_stat_ctrl_service_updating_update(STAT_STATUS_FAIL, CTRL_SERVICE_UNKNOWN, 1);
|
||||
return -1;
|
||||
@@ -573,7 +573,7 @@ int tsg_parse_log_update_payload(const struct streaminfo *a_stream, const void *
|
||||
mpack_node_t params_node = mpack_node_map_cstr(root, "params");
|
||||
if (mpack_node_type(params_node) == mpack_type_nil)
|
||||
{
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_INFO, "PARSE_LOG_UPDATE", "params_node error!");
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_INFO, LOG_MODULE_MPACK, "PARSE_LOG_UPDATE params_node error!");
|
||||
mpack_tree_destroy(&tree);
|
||||
tsg_stat_ctrl_service_updating_update(STAT_STATUS_FAIL, CTRL_SERVICE_UNKNOWN, 1);
|
||||
return -1;
|
||||
@@ -629,7 +629,7 @@ int tsg_parse_log_update_payload(const struct streaminfo *a_stream, const void *
|
||||
|
||||
tsg_stat_ctrl_service_updating_update(STAT_STATUS_FAIL, CTRL_SERVICE_UNKNOWN, 1);
|
||||
|
||||
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_DEBUG, "PDARSE_LOG_UPDATE", "pkt error! there is no log!");
|
||||
MASTER_LOG(g_tsg_para.logger, RLOG_LV_DEBUG, LOG_MODULE_MPACK, "PDARSE_LOG_UPDATE pkt error! there is no log!");
|
||||
mpack_tree_destroy(&tree);
|
||||
return -1;
|
||||
}
|
||||
@@ -18,10 +18,6 @@ enum DEPLOY_MODE
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef PRINTADDR
|
||||
#define PRINTADDR(a, b) ((b)<RLOG_LV_FATAL ? printaddr(&(a->addr), a->threadnum) : "")
|
||||
#endif
|
||||
|
||||
#ifndef MAX_TSG_ALL_RESULT_NUM
|
||||
#define MAX_TSG_ALL_RESULT_NUM MAX_RESULT_NUM*3
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user