From 427a0d7faf42b8e4de1e6918f3f5c13c81bb3c8f Mon Sep 17 00:00:00 2001 From: liuxueli Date: Mon, 13 Sep 2021 15:43:03 +0800 Subject: [PATCH] =?UTF-8?q?TSG-7542:=20=E6=89=A7=E8=A1=8CRST=E5=8A=A8?= =?UTF-8?q?=E4=BD=9C=E4=B9=8B=E5=90=8E=EF=BC=8C=E8=AE=BE=E7=BD=AE=E4=B8=A2?= =?UTF-8?q?=E5=BC=83=E6=95=B4=E4=B8=AA=E6=B5=81=E7=9A=84=E6=A0=87=E5=BF=97?= =?UTF-8?q?=20=E4=BF=AE=E5=A4=8DIP=E5=AE=9A=E4=BD=8D=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E6=9C=80=E5=90=8E=E7=9A=84,=E5=88=86=E5=89=B2=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/tsg_action.cpp | 39 ++++++++++++++++++++++++++------------- src/tsg_send_log.cpp | 1 - 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/tsg_action.cpp b/src/tsg_action.cpp index c64cd62..38ebeca 100644 --- a/src/tsg_action.cpp +++ b/src/tsg_action.cpp @@ -25,20 +25,31 @@ extern "C" int sendpacket_do_checksum(unsigned char *buf, int protocol, int len); -static int set_drop_stream(const struct streaminfo *a_stream) +static int set_drop_stream(const struct streaminfo *a_stream, tsg_protocol_t protocol) { - int opt_value=1; + int ret=0, opt_value=1; MESA_set_stream_opt(a_stream, MSO_DROP_STREAM, (void *)&opt_value, sizeof(opt_value)); MESA_set_stream_opt(a_stream, MSO_DROP_CURRENT_PKT, (void *)&opt_value, sizeof(opt_value)); - int ret=MESA_set_stream_opt(a_stream, MSO_TIMEOUT, (void *)&g_tsg_para.timeout, sizeof(g_tsg_para.timeout)); - if(ret<0) + switch(protocol) { - FS_operate(g_tsg_para.fs2_handle, g_tsg_para.fs2_field_id[TSG_FS2_SET_TIMOUT_FAILED], 0, FS_OP_ADD, 1); - } - else - { - FS_operate(g_tsg_para.fs2_handle, g_tsg_para.fs2_field_id[TSG_FS2_SET_TIMOUT_SUCCESS], 0, FS_OP_ADD, 1); + case PROTO_MAIL: + case PROTO_POP3: + case PROTO_SMTP: + case PROTO_IMAP: + case PROTO_FTP: + ret=MESA_set_stream_opt(a_stream, MSO_TIMEOUT, (void *)&g_tsg_para.timeout, sizeof(g_tsg_para.timeout)); + if(ret<0) + { + FS_operate(g_tsg_para.fs2_handle, g_tsg_para.fs2_field_id[TSG_FS2_SET_TIMOUT_FAILED], 0, FS_OP_ADD, 1); + } + else + { + FS_operate(g_tsg_para.fs2_handle, g_tsg_para.fs2_field_id[TSG_FS2_SET_TIMOUT_SUCCESS], 0, FS_OP_ADD, 1); + } + break; + default: + break; } return STATE_DROPME|STATE_DROPPKT; @@ -512,6 +523,8 @@ static unsigned char do_action_reset(const struct streaminfo *a_stream, Maat_rul opt_value=1; MESA_set_stream_opt(a_stream, MSO_TCP_RST_REMEDY, (void *)&opt_value, sizeof(opt_value)); } + + set_drop_stream(a_stream, protocol); } return STATE_DROPPKT|STATE_DROPME; @@ -524,7 +537,7 @@ static unsigned char do_action_drop(const struct streaminfo *a_stream, Maat_rule case PROTO_DNS: return STATE_GIVEME|STATE_DROPPKT; default: - set_drop_stream(a_stream); + set_drop_stream(a_stream, protocol); if(g_tsg_para.deploy_mode==DEPLOY_MODE_MIRROR) { return do_action_reset(a_stream, p_result, protocol); @@ -621,7 +634,7 @@ static unsigned char do_action_block_xxx(const struct streaminfo *a_stream, Maat break; } - set_drop_stream(a_stream); + set_drop_stream(a_stream, protocol); return STATE_DROPME|STATE_DROPPKT; } @@ -665,7 +678,7 @@ static unsigned char do_action_redirect_xxx(const struct streaminfo *a_stream, M break; case PROTO_HTTP: do_action_redirect_http(a_stream, p_result, user_region); - set_drop_stream(a_stream); + set_drop_stream(a_stream, protocol); break; default: break; @@ -698,7 +711,7 @@ unsigned char tsg_deal_deny_action(const struct streaminfo *a_stream, Maat_rule_ local_state=do_action_drop(a_stream, p_result, protocol); if(protocol==PROTO_DNS && type==ACTION_RETURN_TYPE_APP) { - local_state=set_drop_stream(a_stream); + local_state=set_drop_stream(a_stream, protocol); } break; case TSG_METHOD_TYPE_RESET: diff --git a/src/tsg_send_log.cpp b/src/tsg_send_log.cpp index 0166e37..e4a63eb 100644 --- a/src/tsg_send_log.cpp +++ b/src/tsg_send_log.cpp @@ -239,7 +239,6 @@ static int set_location(struct TLD_handle_t *_handle, struct streaminfo *a_strea len+=string_cat(buff+len, buff_len-len, location_info->province_full); buff[len++]=','; len+=string_cat(buff+len, buff_len-len, location_info->country_full); - buff[len++]=','; TLD_append(_handle, field_name, (void *)buff, TLD_TYPE_STRING); }