mirror of
https://github.com/wangyu-/udp2raw.git
synced 2025-01-19 14:29:34 +08:00
sync easy-tcp and other options from mp version
This commit is contained in:
parent
7de2f800f9
commit
a4aba62656
39
misc.cpp
39
misc.cpp
@ -237,6 +237,10 @@ int process_log_level(int argc,char *argv[])//process --log-level and --disable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(strcmp(argv[i],"--enable-color")==0)
|
||||||
|
{
|
||||||
|
enable_log_color=1;
|
||||||
|
}
|
||||||
if(strcmp(argv[i],"--disable-color")==0)
|
if(strcmp(argv[i],"--disable-color")==0)
|
||||||
{
|
{
|
||||||
enable_log_color=0;
|
enable_log_color=0;
|
||||||
@ -266,6 +270,7 @@ void process_arg(int argc, char *argv[]) //process all options
|
|||||||
{"cipher-mode", required_argument, 0, 1},
|
{"cipher-mode", required_argument, 0, 1},
|
||||||
{"raw-mode", required_argument, 0, 1},
|
{"raw-mode", required_argument, 0, 1},
|
||||||
{"disable-color", no_argument, 0, 1},
|
{"disable-color", no_argument, 0, 1},
|
||||||
|
{"enable-color", no_argument, 0, 1},
|
||||||
{"log-position", no_argument, 0, 1},
|
{"log-position", no_argument, 0, 1},
|
||||||
{"disable-bpf", no_argument, 0, 1},
|
{"disable-bpf", no_argument, 0, 1},
|
||||||
{"disable-anti-replay", no_argument, 0, 1},
|
{"disable-anti-replay", no_argument, 0, 1},
|
||||||
@ -273,7 +278,6 @@ void process_arg(int argc, char *argv[]) //process all options
|
|||||||
{"gen-rule", no_argument, 0, 'g'},
|
{"gen-rule", no_argument, 0, 'g'},
|
||||||
{"gen-add", no_argument, 0, 1},
|
{"gen-add", no_argument, 0, 1},
|
||||||
{"debug", no_argument, 0, 1},
|
{"debug", no_argument, 0, 1},
|
||||||
{"dev", required_argument, 0, 1},
|
|
||||||
{"retry-on-error", no_argument, 0, 1},
|
{"retry-on-error", no_argument, 0, 1},
|
||||||
{"clear", no_argument, 0, 1},
|
{"clear", no_argument, 0, 1},
|
||||||
{"simple-rule", no_argument, 0, 1},
|
{"simple-rule", no_argument, 0, 1},
|
||||||
@ -292,7 +296,9 @@ void process_arg(int argc, char *argv[]) //process all options
|
|||||||
{"max-rst-to-show", required_argument, 0, 1},
|
{"max-rst-to-show", required_argument, 0, 1},
|
||||||
{"max-rst-allowed", required_argument, 0, 1},
|
{"max-rst-allowed", required_argument, 0, 1},
|
||||||
{"set-ttl", required_argument, 0, 1},
|
{"set-ttl", required_argument, 0, 1},
|
||||||
|
{"dev", required_argument, 0, 1},
|
||||||
{"dns-resolve", no_argument, 0, 1},
|
{"dns-resolve", no_argument, 0, 1},
|
||||||
|
{"easy-tcp", no_argument, 0, 1},
|
||||||
{NULL, 0, 0, 0}
|
{NULL, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -495,6 +501,7 @@ void process_arg(int argc, char *argv[]) //process all options
|
|||||||
}
|
}
|
||||||
else if(strcmp(long_options[option_index].name,"raw-mode")==0)
|
else if(strcmp(long_options[option_index].name,"raw-mode")==0)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
for(i=0;i<mode_end;i++)
|
for(i=0;i<mode_end;i++)
|
||||||
{
|
{
|
||||||
if(strcmp(optarg,raw_mode_tostring[i])==0)
|
if(strcmp(optarg,raw_mode_tostring[i])==0)
|
||||||
@ -510,6 +517,30 @@ void process_arg(int argc, char *argv[]) //process all options
|
|||||||
mylog(log_fatal,"no such raw_mode %s\n",optarg);
|
mylog(log_fatal,"no such raw_mode %s\n",optarg);
|
||||||
myexit(-1);
|
myexit(-1);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
if(strcmp(optarg,"easyfaketcp")==0||strcmp(optarg,"easy_faketcp")==0||strcmp(optarg,"easy-faketcp")==0)
|
||||||
|
{
|
||||||
|
raw_mode=mode_faketcp;
|
||||||
|
use_tcp_dummy_socket=1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for(i=0;i<mode_end;i++)
|
||||||
|
{
|
||||||
|
if(strcmp(optarg,raw_mode_tostring[i])==0)
|
||||||
|
{
|
||||||
|
//printf("%d i\n",i);
|
||||||
|
//printf("%s",raw_mode_tostring[i]);
|
||||||
|
raw_mode=(raw_mode_t)i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(i==mode_end)
|
||||||
|
{
|
||||||
|
mylog(log_fatal,"no such raw_mode %s\n",optarg);
|
||||||
|
myexit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(strcmp(long_options[option_index].name,"auth-mode")==0)
|
else if(strcmp(long_options[option_index].name,"auth-mode")==0)
|
||||||
{
|
{
|
||||||
@ -582,6 +613,7 @@ void process_arg(int argc, char *argv[]) //process all options
|
|||||||
{
|
{
|
||||||
sscanf(optarg,"%s",dev);
|
sscanf(optarg,"%s",dev);
|
||||||
//enable_log_color=0;
|
//enable_log_color=0;
|
||||||
|
mylog(log_info,"dev=[%s]\n",dev);
|
||||||
}
|
}
|
||||||
else if(strcmp(long_options[option_index].name,"debug-resend")==0)
|
else if(strcmp(long_options[option_index].name,"debug-resend")==0)
|
||||||
{
|
{
|
||||||
@ -700,6 +732,11 @@ void process_arg(int argc, char *argv[]) //process all options
|
|||||||
enable_dns_resolve=1;
|
enable_dns_resolve=1;
|
||||||
mylog(log_info,"dns-resolve enabled\n");
|
mylog(log_info,"dns-resolve enabled\n");
|
||||||
}
|
}
|
||||||
|
else if(strcmp(long_options[option_index].name,"easy-tcp")==0)
|
||||||
|
{
|
||||||
|
use_tcp_dummy_socket=1;
|
||||||
|
mylog(log_info,"--easy-tcp enabled, now a dummy tcp socket will be created for handshake and block rst\n");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mylog(log_warn,"ignored unknown long option ,option_index:%d code:<%x>\n",option_index, optopt);
|
mylog(log_warn,"ignored unknown long option ,option_index:%d code:<%x>\n",option_index, optopt);
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
int raw_recv_fd=-1;
|
int raw_recv_fd=-1;
|
||||||
int raw_send_fd=-1;
|
int raw_send_fd=-1;
|
||||||
u32_t link_level_header_len=0;//set it to 14 if SOCK_RAW is used in socket(PF_PACKET, SOCK_RAW, htons(ETH_P_IP));
|
u32_t link_level_header_len=0;//set it to 14 if SOCK_RAW is used in socket(PF_PACKET, SOCK_RAW, htons(ETH_P_IP));
|
||||||
|
int use_tcp_dummy_socket=0;
|
||||||
|
|
||||||
int seq_mode=3;
|
int seq_mode=3;
|
||||||
int max_seq_mode=4;
|
int max_seq_mode=4;
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
extern int raw_recv_fd;
|
extern int raw_recv_fd;
|
||||||
extern int raw_send_fd;
|
extern int raw_send_fd;
|
||||||
|
extern int use_tcp_dummy_socket;
|
||||||
extern int seq_mode;
|
extern int seq_mode;
|
||||||
extern int max_seq_mode;
|
extern int max_seq_mode;
|
||||||
extern int filter_port;
|
extern int filter_port;
|
||||||
|
@ -15,8 +15,6 @@
|
|||||||
#include "encrypt.h"
|
#include "encrypt.h"
|
||||||
#include "fd_manager.h"
|
#include "fd_manager.h"
|
||||||
|
|
||||||
int server_easytcp=0;//currently only for test
|
|
||||||
|
|
||||||
int server_on_timer_multi(conn_info_t &conn_info) //for server. called when a timer is ready in epoll.for server,there will be one timer for every connection
|
int server_on_timer_multi(conn_info_t &conn_info) //for server. called when a timer is ready in epoll.for server,there will be one timer for every connection
|
||||||
// there is also a global timer for server,but its not handled here
|
// there is also a global timer for server,but its not handled here
|
||||||
{
|
{
|
||||||
@ -458,7 +456,7 @@ int server_on_raw_recv_multi() //called when server received an raw packet
|
|||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(server_easytcp!=0)
|
if(use_tcp_dummy_socket!=0)
|
||||||
return 0;
|
return 0;
|
||||||
raw_info_t &raw_info=tmp_raw_info;
|
raw_info_t &raw_info=tmp_raw_info;
|
||||||
packet_info_t &send_info=raw_info.send_info;
|
packet_info_t &send_info=raw_info.send_info;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user