52 lines
948 B
C++
Raw Normal View History

2017-08-08 23:34:35 +08:00
#include "common.h"
#include "log.h"
2017-10-26 08:38:52 -05:00
2017-09-14 07:01:39 -05:00
#include "lib/rs.h"
2017-09-15 03:34:29 -05:00
#include "packet.h"
2017-09-25 10:38:39 -05:00
#include "connection.h"
#include "fd_manager.h"
2017-09-23 02:00:44 -05:00
#include "delay_manager.h"
2017-10-05 12:21:06 -05:00
#include "fec_manager.h"
2017-10-26 08:38:52 -05:00
#include "misc.h"
#include "tunnel.h"
2017-10-28 01:02:58 -05:00
//#include "tun_dev.h"
2017-10-21 11:27:39 +08:00
using namespace std;
2017-08-08 17:10:38 +08:00
2017-09-14 12:22:47 -05:00
2017-08-08 23:34:35 +08:00
int main(int argc, char *argv[])
{
2017-10-27 00:03:35 -05:00
//working_mode=tunnel_mode;
2017-09-23 02:00:44 -05:00
2017-08-13 10:19:17 +08:00
assert(sizeof(u64_t)==8);
assert(sizeof(i64_t)==8);
assert(sizeof(u32_t)==4);
assert(sizeof(i32_t)==4);
2017-10-13 10:26:05 -05:00
assert(sizeof(u16_t)==2);
assert(sizeof(i16_t)==2);
2017-08-08 23:34:35 +08:00
dup2(1, 2); //redirect stderr to stdout
int i, j, k;
process_arg(argc,argv);
2017-10-15 14:12:21 -05:00
2017-10-17 12:35:03 -05:00
delay_manager.set_capacity(delay_capacity);
2017-09-25 10:38:39 -05:00
local_ip_uint32=inet_addr(local_ip);
remote_ip_uint32=inet_addr(remote_ip);
2017-10-27 21:16:59 -05:00
sub_net_uint32=inet_addr(sub_net);
if(strlen(tun_dev)==0)
{
sprintf(tun_dev,"tun%u",get_true_random_number()%1000);
}
2017-08-08 23:34:35 +08:00
2017-10-28 01:02:58 -05:00
if(client_or_server==client_mode)
2017-09-25 10:38:39 -05:00
{
2017-10-28 01:02:58 -05:00
tunnel_client_event_loop();
2017-09-25 10:38:39 -05:00
}
else
{
2017-10-28 01:02:58 -05:00
tunnel_server_event_loop();
2017-09-25 10:38:39 -05:00
}
2017-08-08 23:34:35 +08:00
2017-08-08 17:10:38 +08:00
return 0;
}
2017-08-08 23:34:35 +08:00