This commit is contained in:
wangyu- 2017-10-26 08:54:18 -05:00
parent 0a34cb47ab
commit 47d762958f
7 changed files with 31 additions and 28 deletions

View File

@ -20,9 +20,9 @@ int delay_capacity=0;
char iptables_rule[200]="";
//int is_client = 0, is_server = 0;
program_mode_t program_mode=unset_mode;//0 unset; 1client 2server
program_mode_t client_or_server=unset_mode;//0 unset; 1client 2server
working_mode_t working_mode=unset_mode;
struct random_fd_t
{

View File

@ -115,9 +115,12 @@ extern int about_to_exit;
enum raw_mode_t{mode_faketcp=0,mode_udp,mode_icmp,mode_end};
extern raw_mode_t raw_mode;
enum program_mode_t {unset_mode=0,client_mode,server_mode};
extern program_mode_t program_mode;
extern program_mode_t client_or_server;
extern unordered_map<int, const char*> raw_mode_tostring ;
enum working_mode_t {unset_mode=0,tunnel_mode,tun_dev_mode};
extern working_mode_t working_mode;
extern int delay_capacity;

View File

@ -47,7 +47,7 @@ void conv_manager_t::clear()
{
//if(disable_conv_clear) return ;//////what was the purpose of this code?
if(program_mode==server_mode)
if(client_or_server==server_mode)
{
for(auto it=conv_to_u64.begin();it!=conv_to_u64.end();it++)
{
@ -111,7 +111,7 @@ int conv_manager_t::erase_conv(u32_t conv)
//if(disable_conv_clear) return 0;
assert(conv_last_active_time.find(conv)!=conv_last_active_time.end());
u64_t u64=conv_to_u64[conv];
if(program_mode==server_mode)
if(client_or_server==server_mode)
{
server_clear_function(u64);
}

View File

@ -14,20 +14,9 @@ using namespace std;
int main(int argc, char *argv[])
{
working_mode=tun_dev_mode;
/*
if(argc==1||argc==0)
{
printf("this_program classic\n");
printf("this_program fec\n");
return 0;
}*/
/*
if(argc>=2&&strcmp(argv[1],"fec")!=0)
{
printf("running into classic mode!\n");
return classic::main(argc,argv);
}*/
assert(sizeof(u64_t)==8);
assert(sizeof(i64_t)==8);
@ -43,13 +32,25 @@ int main(int argc, char *argv[])
local_ip_uint32=inet_addr(local_ip);
remote_ip_uint32=inet_addr(remote_ip);
if(program_mode==client_mode)
if(working_mode==tunnel_mode)
{
client_event_loop();
if(client_or_server==client_mode)
{
tunnel_client_event_loop();
}
else
{
tunnel_server_event_loop();
}
}
else
{
server_event_loop();
if(client_or_server==client_mode)
{
}
else
{
}
}
return 0;

View File

@ -41,7 +41,6 @@ int time_mono_test=0;
int socket_buf_size=1024*1024;
int from_normal_to_fec(conn_info_t & conn_info,char *data,int len,int & out_n,char **&out_arr,int *&out_len,my_time_t *&out_delay)
{
@ -899,11 +898,11 @@ void process_arg(int argc, char *argv[])
}
if(is_client==1)
{
program_mode=client_mode;
client_or_server=client_mode;
}
else
{
program_mode=server_mode;
client_or_server=server_mode;
}
print_parameter();

View File

@ -65,7 +65,7 @@ int new_connected_socket(int &fd,u32_t ip,int port)
return 0;
}
int client_event_loop()
int tunnel_client_event_loop()
{
//char buf[buf_len];
int i, j, k;int ret;
@ -392,7 +392,7 @@ int client_event_loop()
return 0;
}
int server_event_loop()
int tunnel_server_event_loop()
{
//char buf[buf_len];
int i, j, k;int ret;

View File

@ -11,7 +11,7 @@
#include "misc.h"
int client_event_loop();
int server_event_loop();
int tunnel_client_event_loop();
int tunnel_server_event_loop();
#endif /* TUNNEL_H_ */