控制报文log_update,增加proxy_rule_list和proxy_action字段

This commit is contained in:
wangmenglan
2023-11-21 17:42:28 +08:00
parent 70dab4a183
commit 15582f5d51

View File

@@ -758,7 +758,10 @@ static void send_event_log(struct session_ctx *s_ctx, int thread_seq, void *ctx)
marsio_buff_t *tx_buffs[1];
struct metadata meta = {0};
void * logger = thread->logger;
int ret = 0;
uint8_t hit_no_intercept = 0;
uint64_t rule_id = 0;
uint16_t length = 0;
uint8_t ssl_intercept_status = 0;
uint64_t ssl_upstream_latency = 0;
@@ -777,7 +780,12 @@ static void send_event_log(struct session_ctx *s_ctx, int thread_seq, void *ctx)
char *data = NULL;
size_t size;
mpack_writer_t writer;
if (s_ctx->protocol != STREAM_PROTO_SSL)
ret = tfe_cmsg_get_value(s_ctx->cmsg, TFE_CMSG_POLICY_ID, (unsigned char *)&rule_id, sizeof(rule_id), &length);
if (ret < 0)
return;
ret = tfe_cmsg_get_value(s_ctx->cmsg, TFE_CMSG_HIT_NO_INTERCEPT, (unsigned char *)&hit_no_intercept, sizeof(hit_no_intercept), &length);
if (ret < 0)
return;
mpack_writer_init_growable(&writer, &data, &size);
@@ -808,6 +816,10 @@ static void send_event_log(struct session_ctx *s_ctx, int thread_seq, void *ctx)
mpack_write_cstr(&writer, "ssl_intercept_info");
mpack_build_array(&writer);
// proxy rule list
mpack_build_array(&writer);
mpack_write_u64(&writer, rule_id);
mpack_complete_array(&writer);
tfe_cmsg_get_value(s_ctx->cmsg, TFE_CMSG_SSL_INTERCEPT_STATE, (unsigned char *)&ssl_intercept_status, sizeof(ssl_intercept_status), &length);
@@ -827,6 +839,7 @@ static void send_event_log(struct session_ctx *s_ctx, int thread_seq, void *ctx)
tfe_cmsg_get_value(s_ctx->cmsg, TFE_CMSG_SSL_PASSTHROUGH_REASON, (unsigned char *)ssl_passthrough_reason, sizeof(ssl_passthrough_reason), &ssl_passthrough_reason_length);
mpack_write_u8(&writer, hit_no_intercept?0:1);
mpack_write_u8(&writer, ssl_intercept_status);
mpack_write_u64(&writer, ssl_upstream_latency);
mpack_write_u64(&writer, ssl_downstream_latency);
@@ -994,6 +1007,7 @@ static int handle_session_opening(struct metadata *meta, struct ctrl_pkt_parser
uint8_t hit_no_intercept = 0;
uint16_t out_size = 0;
char stream_traceid[24] = {0};
char reason_no_intercept_param[] = "Hit No Intercept Policy";
char reason_invalid_intercept_param[] = "Invalid Intercept Param";
char reason_invalid_tcp_policy_param[] = "Invalid tcp policy Param";
char reason_underlying_stream_error[] = "Underlying Stream Error";
@@ -1044,6 +1058,7 @@ static int handle_session_opening(struct metadata *meta, struct ctrl_pkt_parser
tfe_cmsg_get_value(parser->cmsg, TFE_CMSG_HIT_NO_INTERCEPT, (unsigned char *)&hit_no_intercept, sizeof(hit_no_intercept), &out_size);
if (hit_no_intercept == 1) {
is_passthrough = 1;
set_passthrough_reason(parser->cmsg, reason_no_intercept_param);
goto passthrough;
}