From b1239d556e1f930417477a14fe0065197c3bd286 Mon Sep 17 00:00:00 2001 From: yangwenlin Date: Tue, 11 Jan 2022 19:26:10 +0800 Subject: [PATCH] =?UTF-8?q?TSG-9215:=20=E4=BF=AE=E5=A4=8Dtamper=E5=91=BD?= =?UTF-8?q?=E4=B8=ADtcp=E5=90=8E=E5=8F=91=E9=80=81=E4=B8=A4=E6=AC=A1?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=8C=85=E9=97=AE=E9=A2=98=EF=BC=8C=E9=87=8D?= =?UTF-8?q?=E6=96=B0=E9=AA=8C=E8=AF=81=E5=90=88=E5=85=A5=EF=BC=8C=E4=B9=8B?= =?UTF-8?q?=E5=89=8D=E5=90=88=E5=85=A5=E7=9A=84=E4=BB=A3=E7=A0=81=E8=A2=AB?= =?UTF-8?q?=E8=A6=86=E7=9B=96=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/tsg_action.cpp | 15 +++++++-------- src/tsg_entry.cpp | 15 ++++----------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/tsg_action.cpp b/src/tsg_action.cpp index 9d5c42e..ea7e942 100644 --- a/src/tsg_action.cpp +++ b/src/tsg_action.cpp @@ -587,29 +587,28 @@ static unsigned char do_action_tamper(const struct streaminfo *a_stream, Maat_ru memset(_context, 0, sizeof(struct tcpall_context)); set_struct_project(a_stream, g_tsg_para.tcpall_project_id, (void *)_context); _context->method_type=TSG_METHOD_TYPE_TAMPER; - _context->tamper_count = 1; + _context->tamper_count = -1; }else{ if(_context->method_type != TSG_METHOD_TYPE_TAMPER) { _context->method_type=TSG_METHOD_TYPE_TAMPER; - _context->tamper_count = 1; + _context->tamper_count = -1; } else { - //to do error log - //_context->method_type MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_DEBUG, __FUNCTION__, - "_context->method_type : %d", + "Tamper is been processed, _context->method_type : %d", _context->method_type); - return STATE_GIVEME; } } - if(0 == send_tamper_xxx(a_stream, &_context->tamper_count, user_data)){ - return STATE_DROPPKT; + if(a_stream->type != STREAM_TYPE_TCP){ + if(0 == send_tamper_xxx(a_stream, &_context->tamper_count, user_data)){ + return STATE_DROPPKT; + } } return STATE_GIVEME; } diff --git a/src/tsg_entry.cpp b/src/tsg_entry.cpp index 7fd456b..08f3138 100644 --- a/src/tsg_entry.cpp +++ b/src/tsg_entry.cpp @@ -1842,18 +1842,11 @@ static unsigned char tsg_master_all_entry(const struct streaminfo *a_stream, uns } break; case TSG_METHOD_TYPE_TAMPER: - if(0 == send_tamper_xxx(a_stream, &context->tamper_count, a_packet)){ - state|=APP_STATE_GIVEME|APP_STATE_DROPPKT; - }else{ - state=APP_STATE_GIVEME; + if(a_stream->opstate != OP_STATE_PENDING){ + if(0 == send_tamper_xxx(a_stream, &context->tamper_count, a_packet)){ + state|=APP_STATE_GIVEME|APP_STATE_DROPPKT; + } } - context->tamper_count += 1; - MESA_handle_runtime_log(g_tsg_para.logger, - RLOG_LV_DEBUG, - __FUNCTION__, - "Addr: %s, send_tamper_xxx num %ld", - PRINTADDR(a_stream, g_tsg_para.level), - context->tamper_count); break; case TSG_METHOD_TYPE_DEFAULT: if(!is_do_default_policy(a_stream, context->after_n_packets) || stream_state==OP_STATE_CLOSE)