Compare commits

...

13 Commits

Author SHA1 Message Date
wangyu-
28e182cea4 changed -h page 2017-11-18 09:51:50 -06:00
wangyu-
65cacab30a Merge branch 'master' of https://github.com/wangyu-/udp2raw-tunnel 2017-11-18 09:50:30 -06:00
wangyu-
fb330f3700 new option mtu-warn 2017-11-18 09:50:23 -06:00
wangyu-
bf9a98edab Update README.zh-cn.md 2017-11-18 02:11:46 -08:00
wangyu-
8cee48bd69 Update README.zh-cn.md 2017-11-18 02:10:59 -08:00
wangyu-
6f2a286168 Merge branch 'master' of https://github.com/wangyu-/udp2raw-tunnel 2017-11-17 02:17:53 -06:00
wangyu-
2610760b61 increased conv_timeout to 180s 2017-11-17 02:17:41 -06:00
wangyu-
1988bff9ba Update README.zh-cn.md 2017-11-14 21:20:02 -08:00
wangyu-
2a16a198b3 Add files via upload 2017-11-15 13:15:21 +08:00
wangyu-
400e148bce Delete udp2rawopenvpn.PNG 2017-11-14 21:14:49 -08:00
wangyu-
58eae7736a Update README.zh-cn.md 2017-11-11 14:35:08 -08:00
wangyu-
9dc2e5a391 trival 2017-11-11 01:58:21 -06:00
wangyu-
e41accc38c help page 2017-11-11 01:46:58 -06:00
5 changed files with 27 additions and 15 deletions

View File

@@ -1,4 +1,4 @@
Udp2raw-tunnel # Udp2raw-tunnel
![image2](/images/image2.PNG) ![image2](/images/image2.PNG)
udp2raw tunnel通过raw socket给UDP包加上TCP或ICMP header进而绕过UDP屏蔽或QoS或在UDP不稳定的环境下提升稳定性。可以有效防止在使用kcptun或者finalspeed的情况下udp端口被运营商限速。 udp2raw tunnel通过raw socket给UDP包加上TCP或ICMP header进而绕过UDP屏蔽或QoS或在UDP不稳定的环境下提升稳定性。可以有效防止在使用kcptun或者finalspeed的情况下udp端口被运营商限速。
@@ -52,7 +52,7 @@ NAT 穿透 tcp icmp udp模式都支持nat穿透。
支持Openwrt没有编译依赖容易编译到任何平台上。release中提供了ar71xx版本的binary 支持Openwrt没有编译依赖容易编译到任何平台上。release中提供了ar71xx版本的binary
epoll纯异步高并发除了回收过期连接外所有操作的时间复杂度都跟连接数无关。回收过期连接的操做也是柔和进行的不会因为消耗太多cpu时间造成延迟抖动。 epoll实现高并发除了回收过期连接外所有操作的时间复杂度都跟连接数无关。回收过期连接的操做也是柔和进行的不会因为消耗太多cpu时间造成延迟抖动。
### 关键词 ### 关键词
突破udp qos,突破udp屏蔽openvpn tcp over tcp problem,openvpn over icmp,udp to icmp tunnel,udp to tcp tunnel,udp via icmp,udp via tcp 突破udp qos,突破udp屏蔽openvpn tcp over tcp problem,openvpn over icmp,udp to icmp tunnel,udp to tcp tunnel,udp via icmp,udp via tcp
@@ -162,14 +162,14 @@ facktcp模式并没有模拟tcp的全部。所以理论上有办法把faketcp和
### `--keep-rule` ### `--keep-rule`
定期主动检查iptables如果udp2raw添加的iptables规则丢了就重新添加。在一些iptables可能会被其他程序清空的情况下(比如梅林固件和openwrt的路由器)格外有用。 定期主动检查iptables如果udp2raw添加的iptables规则丢了就重新添加。在一些iptables可能会被其他程序清空的情况下(比如梅林固件和openwrt的路由器)格外有用。
### `--lower-level`
大部分udp2raw不能连通的情况都是设置了不兼容的iptables造成的。--lower-level选项允许绕过本地iptables。在一些iptables不好改动的情况下尤其有效比如你用的是梅林固件iptables全是固件自己生成的
### `--fifo` ### `--fifo`
指定一个fifo(named pipe)来向运行中的程序发送命令,例如`--fifo fifo.file` 指定一个fifo(named pipe)来向运行中的程序发送命令,例如`--fifo fifo.file`
在client端,可以用`echo reconnect >fifo.file`来强制client换端口重连上层不断线.对Server目前没有效果。 在client端,可以用`echo reconnect >fifo.file`来强制client换端口重连上层不断线.对Server目前没有效果。
### `--lower-level`
大部分udp2raw不能连通的情况都是设置了不兼容的iptables造成的。--lower-level选项允许绕过本地iptables。在一些iptables不好改动的情况下尤其有效比如你用的是梅林固件iptables全是固件自己生成的
##### 格式 ##### 格式
`if_name#dest_mac_adress`,例如 `eth0#00:23:45:67:89:b9``eth0`换成你的出口网卡名。`00:23:45:67:89:b9`换成网关的mac地址如果client和server在同一个局域网内可能不需要网关这时候直接用对方主机的mac地址这个属于罕见的应用场景可以忽略 `if_name#dest_mac_adress`,例如 `eth0#00:23:45:67:89:b9``eth0`换成你的出口网卡名。`00:23:45:67:89:b9`换成网关的mac地址如果client和server在同一个局域网内可能不需要网关这时候直接用对方主机的mac地址这个属于罕见的应用场景可以忽略

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 58 KiB

View File

@@ -7,8 +7,6 @@
#include "encrypt.h" #include "encrypt.h"
#include "fd_manager.h" #include "fd_manager.h"
int mtu_warn=1375;//if a packet larger than mtu warn is receviced,there will be a warning
char hb_buf[buf_len]; char hb_buf[buf_len];
@@ -229,11 +227,6 @@ int client_on_timer(conn_info_t &conn_info) //for client. called when a timer is
return 0; return 0;
} }
if(get_current_time()-conn_info.last_hb_sent_time<heartbeat_interval)
{
return 0;
}
if(get_current_time()- conn_info.last_oppsite_roller_time>client_conn_uplink_timeout) if(get_current_time()- conn_info.last_oppsite_roller_time>client_conn_uplink_timeout)
{ {
conn_info.state.client_current_state=client_idle; conn_info.state.client_current_state=client_idle;
@@ -241,6 +234,14 @@ int client_on_timer(conn_info_t &conn_info) //for client. called when a timer is
mylog(log_info,"state back to client_idle from client_ready bc of client-->server direction timeout\n"); mylog(log_info,"state back to client_idle from client_ready bc of client-->server direction timeout\n");
} }
if(get_current_time()-conn_info.last_hb_sent_time<heartbeat_interval)
{
return 0;
}
mylog(log_debug,"heartbeat sent <%x,%x>\n",conn_info.oppsite_id,conn_info.my_id); mylog(log_debug,"heartbeat sent <%x,%x>\n",conn_info.oppsite_id,conn_info.my_id);
if(hb_mode==0) if(hb_mode==0)

View File

@@ -16,6 +16,9 @@
int hb_mode=1; int hb_mode=1;
int hb_len=1200; int hb_len=1200;
int mtu_warn=1375;//if a packet larger than mtu warn is receviced,there will be a warning
fd_manager_t fd_manager; fd_manager_t fd_manager;
char local_ip[100]="0.0.0.0", remote_ip[100]="255.255.255.255",source_ip[100]="0.0.0.0";//local_ip is for -l option,remote_ip for -r option,source for --source-ip char local_ip[100]="0.0.0.0", remote_ip[100]="255.255.255.255",source_ip[100]="0.0.0.0";//local_ip is for -l option,remote_ip for -r option,source for --source-ip
@@ -152,7 +155,8 @@ void print_help()
printf(" the parameter automatically,specify it manually if 'auto' failed\n"); printf(" the parameter automatically,specify it manually if 'auto' failed\n");
printf(" --gen-add generate iptables rule and add it permanently,then exit.overrides -g\n"); printf(" --gen-add generate iptables rule and add it permanently,then exit.overrides -g\n");
printf(" --keep-rule monitor iptables and auto re-add if necessary.implys -a\n"); printf(" --keep-rule monitor iptables and auto re-add if necessary.implys -a\n");
printf(" --hb-len <number> length of heart-beat packet\n"); printf(" --hb-len <number> length of heart-beat packet, >=0 and <=1500\n");
printf(" --mtu-warn <number> mtu warning threshold, unit:byte, default:1375\n");
printf(" --clear clear any iptables rules added by this program.overrides everything\n"); printf(" --clear clear any iptables rules added by this program.overrides everything\n");
printf(" -h,--help print this help message\n"); printf(" -h,--help print this help message\n");
@@ -253,6 +257,7 @@ void process_arg(int argc, char *argv[]) //process all options
{"fifo", required_argument, 0, 1}, {"fifo", required_argument, 0, 1},
{"hb-mode", required_argument, 0, 1}, {"hb-mode", required_argument, 0, 1},
{"hb-len", required_argument, 0, 1}, {"hb-len", required_argument, 0, 1},
{"mtu-warn", required_argument, 0, 1},
{NULL, 0, 0, 0} {NULL, 0, 0, 0}
}; };
@@ -607,7 +612,12 @@ void process_arg(int argc, char *argv[]) //process all options
assert(hb_len>=0&&hb_len<=1500); assert(hb_len>=0&&hb_len<=1500);
mylog(log_info,"hb_len =%d \n",hb_len); mylog(log_info,"hb_len =%d \n",hb_len);
} }
else if(strcmp(long_options[option_index].name,"mtu-warn")==0)
{
sscanf(optarg,"%d",&mtu_warn);
assert(mtu_warn>0);
mylog(log_info,"mtu_warn=%d \n",mtu_warn);
}
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);

3
misc.h
View File

@@ -15,6 +15,7 @@
extern int hb_mode; extern int hb_mode;
extern int hb_len; extern int hb_len;
extern int mtu_warn;
const u32_t max_handshake_conn_num=10000; const u32_t max_handshake_conn_num=10000;
const u32_t max_ready_conn_num=1000; const u32_t max_ready_conn_num=1000;
@@ -41,7 +42,7 @@ const u32_t heartbeat_interval=600;//ms
const u32_t timer_interval=400;//ms. this should be smaller than heartbeat_interval and retry interval; const u32_t timer_interval=400;//ms. this should be smaller than heartbeat_interval and retry interval;
const uint32_t conv_timeout=120000; //ms. 120 second const uint32_t conv_timeout=180000; //ms. 120 second
//const u32_t conv_timeout=30000; //for test //const u32_t conv_timeout=30000; //for test
const u32_t client_conn_timeout=10000;//ms. const u32_t client_conn_timeout=10000;//ms.