From 0e23a077ddf417fc0656c84b959630323a90e9c8 Mon Sep 17 00:00:00 2001 From: liuyang Date: Wed, 12 Dec 2018 16:40:04 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81thread=5Fnum=E9=80=9A=E8=BF=87tfe=5Fp?= =?UTF-8?q?roxy=5Fget=5Fwork=5Fthread=5Fcount()=E5=87=BD=E6=95=B0=E8=8E=B7?= =?UTF-8?q?=E5=BE=97=EF=BC=9B2=E3=80=81=E6=AF=8F=E4=B8=AA=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=8C=85TCP=E8=B4=9F=E8=BD=BD=E6=9C=80=E5=A4=A7?= =?UTF-8?q?=E9=95=BF=E5=BA=A6=E6=9C=89MTU=E6=9B=B4=E6=94=B9=E4=B8=BAmtu-si?= =?UTF-8?q?zeof(struct=20mesa=5Ftcp=5Fhdr)=20-=20sizeof(struct=20mesa=5Fip?= =?UTF-8?q?4=5Fhdr);?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/decrypt_mirror_plugin.cpp | 18 +++++++++--------- .../decrypt-mirroring/src/mirror_stream.cpp | 17 ++++++++++++++--- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/plugin/business/decrypt-mirroring/src/decrypt_mirror_plugin.cpp b/plugin/business/decrypt-mirroring/src/decrypt_mirror_plugin.cpp index 481c9c1..697c091 100644 --- a/plugin/business/decrypt-mirroring/src/decrypt_mirror_plugin.cpp +++ b/plugin/business/decrypt-mirroring/src/decrypt_mirror_plugin.cpp @@ -1,32 +1,32 @@ #include "mirror_stream.h" #include -#include #include #include + +extern unsigned int tfe_proxy_get_work_thread_count(void); + int decrypt_mirror_init(struct tfe_proxy * proxy) { const char* filepath="./conf/tfe/decrypt_mirror.conf"; - int thread_num=2; - UNUSED int ret=0;//todo: aquire from proxy; + int ret=0; + int thread_num = tfe_proxy_get_work_thread_count(); ret=mirror_stream_init(thread_num, filepath); -// assert(ret==0); - return 0; + return ret; } int decrypt_mirror_on_open_cb(const struct tfe_stream * stream, unsigned int thread_id, enum tfe_conn_dir dir, void ** pme) { - UNUSED int ret=0; + int ret=0; ret=mirror_stream_open(thread_id, stream->addr, pme); -// assert(ret==0); - return 0; + return ret; } enum tfe_stream_action decrypt_mirror_on_data_cb(const struct tfe_stream * stream, unsigned int thread_id, enum tfe_conn_dir dir, const unsigned char * data, size_t len, void ** pme) { - UNUSED int ret=0; + int ret=0; ret=mirror_stream_write(dir, data,len, pme, thread_id); return ACTION_FORWARD_DATA; } diff --git a/plugin/business/decrypt-mirroring/src/mirror_stream.cpp b/plugin/business/decrypt-mirroring/src/mirror_stream.cpp index 6533d39..ba89855 100644 --- a/plugin/business/decrypt-mirroring/src/mirror_stream.cpp +++ b/plugin/business/decrypt-mirroring/src/mirror_stream.cpp @@ -553,7 +553,9 @@ int mirror_stream_write(int cur_dir,const unsigned char * data, size_t len, void const unsigned char* payload=data; int payload_len=0; int remain_len=len; - int pkt_num=(len/(g_deliver_globle_info.sendinfo.mtu))+1; + int max_payloadlen_per=0; + int pkt_num=0; +// int pkt_num=(len/(g_deliver_globle_info.sendinfo.mtu))+1; struct deliver_pme_info* pmeinfo=(struct deliver_pme_info*)*pme; @@ -565,22 +567,31 @@ int mirror_stream_write(int cur_dir,const unsigned char * data, size_t len, void if(pmeinfo->addr_info->addrtype==TFE_ADDR_STREAM_TUPLE4_V4) { deliver_debug_log_v4(RLOG_LV_DEBUG,(char*)DELIVER_RECVPKT_DEBUG,pmeinfo,DELIVER_FLAG_RECVPKT,len); + max_payloadlen_per=g_deliver_globle_info.sendinfo.mtu-sizeof(struct mesa_tcp_hdr)-sizeof(struct mesa_ip4_hdr); } else if(pmeinfo->addr_info->addrtype==TFE_ADDR_STREAM_TUPLE4_V6) { deliver_debug_log_v6(RLOG_LV_DEBUG,(char*)DELIVER_RECVPKT_DEBUG,pmeinfo,DELIVER_FLAG_RECVPKT,len); + max_payloadlen_per=g_deliver_globle_info.sendinfo.mtu-sizeof(struct mesa_tcp_hdr)-sizeof(struct mesa_ip6_hdr); } else { //TODO } + + pkt_num=(len/(max_payloadlen_per))+1; for(i=0;iaddr_info->addrtype==TFE_ADDR_STREAM_TUPLE4_V4) { @@ -760,7 +771,7 @@ int mirror_stream_init(int thread_num, const char* filepath) g_deliver_globle_info.sendinfo.send_socket=(int*)malloc(g_deliver_globle_info.sendinfo.thread_num*sizeof(int)); for(i=0;i