From de80871a71739174d6f5c233da380a55588a0d6f Mon Sep 17 00:00:00 2001 From: wangyu Date: Sat, 5 Aug 2017 10:03:40 +0800 Subject: [PATCH] refactor --- common.cpp | 2 +- common.h | 3 +- main.cpp | 173 +++++++++++++++++++++++++++++++---------------------- 3 files changed, 103 insertions(+), 75 deletions(-) diff --git a/common.cpp b/common.cpp index 2810285..15969e4 100644 --- a/common.cpp +++ b/common.cpp @@ -79,7 +79,7 @@ int clear_iptables_rule() } else { - mylog(log_error,"auto added iptables failed by: %s\n",buf); + mylog(log_error,"clear iptables failed by: %s\n",buf); } } diff --git a/common.h b/common.h index cae85a1..c2e0446 100644 --- a/common.h +++ b/common.h @@ -78,8 +78,7 @@ const u32_t conv_clear_interval=1000; const u32_t conn_clear_interval=1000; -const int max_fail_time=100000; - +const i32_t max_fail_time=0;//disable const u32_t heartbeat_interval=1000; diff --git a/main.cpp b/main.cpp index c2a8522..1acbd83 100755 --- a/main.cpp +++ b/main.cpp @@ -529,8 +529,8 @@ int TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT int server_on_raw_recv_pre_ready(conn_info_t &conn_info,u32_t tmp_oppsite_const_id); -int server_on_raw_recv_ready(conn_info_t &conn_info); -int server_on_raw_recv_handshake1(conn_info_t &conn_info,id_t tmp_oppsite_id ); +int server_on_raw_recv_ready(conn_info_t &conn_info,char *data,int data_len); +int server_on_raw_recv_handshake1(conn_info_t &conn_info,char * data, int data_len); int DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD; ////////////////=======================declear divider============================= @@ -924,7 +924,7 @@ int client_on_timer(conn_info_t &conn_info) //for client if(conn_info.state.client_current_state==client_idle) { fail_time_counter++; - if(fail_time_counter>max_fail_time) + if(max_fail_time>0&&fail_time_counter>max_fail_time) { mylog(log_fatal,"max_fail_time exceed\n"); myexit(-1); @@ -1347,7 +1347,68 @@ int client_on_raw_recv(conn_info_t &conn_info) } return 0; } +int server_on_raw_recv_handshake1(conn_info_t &conn_info,char * data, int data_len) +{ + packet_info_t &send_info=conn_info.raw_info.send_info; + packet_info_t &recv_info=conn_info.raw_info.recv_info; + raw_info_t &raw_info=conn_info.raw_info; + u32_t ip=conn_info.raw_info.recv_info.src_ip; + uint16_t port=conn_info.raw_info.recv_info.src_port; + + char ip_port[40]; + sprintf(ip_port,"%s:%d",my_ntoa(ip),port); + + if(data_len