From 4ce3661b011b4b3287ba0340ad574ab06eb82a23 Mon Sep 17 00:00:00 2001 From: "U-DESKTOP-T772REH\\wangyu" Date: Sat, 23 Jun 2018 12:08:28 +0800 Subject: [PATCH] change assert to log fatal --- common.cpp | 10 +++++++--- connection.cpp | 3 ++- main.cpp | 2 +- misc.cpp | 26 ++++++++++++++++++-------- network.cpp | 17 +++++++++-------- 5 files changed, 37 insertions(+), 21 deletions(-) diff --git a/common.cpp b/common.cpp index 5af679d..2133fab 100644 --- a/common.cpp +++ b/common.cpp @@ -317,7 +317,9 @@ int set_buf_size(int fd,int socket_buf_size,int force_socket_buf) { if(force_socket_buf) { - assert(0==1); + mylog(log_fatal,"force_socket_buf not supported in this verion\n"); + myexit(-1); + //assert(0==1); #if 0 if(setsockopt(fd, SOL_SOCKET, SO_SNDBUFFORCE, &socket_buf_size, sizeof(socket_buf_size))<0) { @@ -555,7 +557,8 @@ int read_file(const char * file,string &output) } int run_command(string command0,char * &output,int flag) { - assert(0==1 && "not implemented\n"); + mylog(log_fatal,"run_command not supported in this version\n"); + myexit(-1); #if 0 FILE *in; @@ -766,7 +769,8 @@ int create_fifo(char * file) setnonblocking(fifo_fd); return fifo_fd; #else - assert(0==1&&"not implemented"); + mylog(log_fatal,"--fifo not supported in this version\n"); + myexit(-1); return 0; #endif } diff --git a/connection.cpp b/connection.cpp index 9f64bbf..9d92565 100644 --- a/connection.cpp +++ b/connection.cpp @@ -725,7 +725,8 @@ int reserved_parse_safer(conn_info_t &conn_info,const char * input,int input_len } else { - assert(0==1); + mylog(log_fatal,"unknow hb_mode\n"); + myexit(-1); } diff --git a/main.cpp b/main.cpp index 57b1593..be95511 100755 --- a/main.cpp +++ b/main.cpp @@ -1126,7 +1126,7 @@ int main(int argc, char *argv[]) } else { - mylog(log_fatal,"server mode not supported in portable version\n"); + mylog(log_fatal,"server mode not supported in multi-platform version\n"); myexit(-1); //server_event_loop(); } diff --git a/misc.cpp b/misc.cpp index 0ec9e10..c77a21e 100644 --- a/misc.cpp +++ b/misc.cpp @@ -449,7 +449,8 @@ void process_arg(int argc, char *argv[]) //process all options case 'h': break; case 'a': - assert(0==1&&"-a not implemented"); + mylog(log_fatal,"-a not supported in this version, check -g or --mode easyfaketcp\n") + myexit(-1); auto_add_iptables_rule=1; break; case 'g': @@ -463,7 +464,9 @@ void process_arg(int argc, char *argv[]) //process all options mylog(log_debug,"option_index: %d\n",option_index); if(strcmp(long_options[option_index].name,"clear")==0) { - assert(0==1&&"--clear not implemented"); + mylog(log_fatal,"--clear not supported in this version\n") + myexit(-1); + clear_iptables=1; } else if(strcmp(long_options[option_index].name,"source-ip")==0) @@ -546,24 +549,29 @@ void process_arg(int argc, char *argv[]) //process all options } else if(strcmp(long_options[option_index].name,"lower-level")==0) { - assert(0==1); + mylog(log_fatal,"--lower-level not supported in this version\n") + myexit(-1); //process_lower_level_arg(); //lower_level=1; //strcpy(lower_level_arg,optarg); } else if(strcmp(long_options[option_index].name,"simple-rule")==0) { - assert(0==1&&"--simple-rule not implemented"); + mylog(log_fatal,"--simple-rule not supported in this version\n") + myexit(-1); + simple_rule=1; } else if(strcmp(long_options[option_index].name,"keep-rule")==0) { - assert(0==1&&"--keep-rule not implemented"); + mylog(log_fatal,"--keep-rule not supported in this version\n") + myexit(-1); keep_rule=1; } else if(strcmp(long_options[option_index].name,"gen-add")==0) { - assert(0==1&&"--gen-add not implemented"); + mylog(log_fatal,"--gen-add not supported in this version\n") + myexit(-1); generate_iptables_rule_add=1; } else if(strcmp(long_options[option_index].name,"disable-color")==0) @@ -590,7 +598,8 @@ void process_arg(int argc, char *argv[]) //process all options } else if(strcmp(long_options[option_index].name,"force-sock-buf")==0) { - assert(0==1&&"--force-sock-buf not implemented"); + mylog(log_fatal,"--force-sock-buf not supported in this version\n") + myexit(-1); force_socket_buf=1; } else if(strcmp(long_options[option_index].name,"retry-on-error")==0) @@ -647,7 +656,8 @@ void process_arg(int argc, char *argv[]) //process all options } else if(strcmp(long_options[option_index].name,"fifo")==0) { - assert(0==1&&"--fifo not implemented"); + mylog(log_fatal,"--fifo not supported in this version\n") + myexit(-1); sscanf(optarg,"%s",fifo_file); mylog(log_info,"fifo_file =%s \n",fifo_file); diff --git a/network.cpp b/network.cpp index 5f9a83c..02f095c 100644 --- a/network.cpp +++ b/network.cpp @@ -276,10 +276,10 @@ void *pcap_recv_thread_entry(void *none) myexit(-1); break; case -2: - assert(0==1); + assert(0==1);// break; default: - assert(0==1); + assert(0==1);// } } myexit(-1);*/ @@ -332,7 +332,7 @@ int init_raw_socket() if( ret < 0 ) { printf("pcap_activate failed %s\n", pcap_geterr(pcap_handle)); - assert(0==1); + myexit(-1); } @@ -360,13 +360,13 @@ int init_raw_socket() if (pcap_compile(pcap_handle, &g_filter, filter_exp, 0, PCAP_NETMASK_UNKNOWN ) == -1) { printf("Bad filter - %s\n", pcap_geterr(pcap_handle)); - assert(0==1); + myexit(-1); } if (pcap_setfilter(pcap_handle, &g_filter) == -1) { printf("Error setting filter - %s\n", pcap_geterr(pcap_handle)); - assert(0==1); + myexit(-1); } @@ -496,7 +496,8 @@ void init_filter(int port) } else { - assert(0==1); + mylog(log_fatal,"unknow raw mode\n"); + myexit(-1); } mylog(log_info,"filter expression is [%s]\n",filter_exp); @@ -507,13 +508,13 @@ void init_filter(int port) if (pcap_compile(pcap_handle, &g_filter, filter_exp, 0, PCAP_NETMASK_UNKNOWN ) == -1) { mylog(log_fatal,"Bad filter - %s\n", pcap_geterr(pcap_handle)); - assert(0==1); + myexit(-1); } if (pcap_setfilter(pcap_handle, &g_filter) == -1) { mylog(log_fatal,"Error setting filter - %s\n", pcap_geterr(pcap_handle)); - assert(0==1); + myexit(-1); } //pthread_mutex_unlock(&filter_mutex);