Compare commits

..

34 Commits

Author SHA1 Message Date
wangyu-
1628c15fcb new option hb-len 2017-11-11 01:15:50 -06:00
wangyu-
79855b445d Merge branch 'master' of https://github.com/wangyu-/udp2raw-tunnel 2017-11-11 01:07:57 -06:00
wangyu-
9e010c7f97 improve heartbeat 2017-11-11 01:07:28 -06:00
wangyu-
dce81b3fbf Update README.md 2017-11-09 17:02:02 -08:00
wangyu-
24310edd35 tuned parameter 2017-11-09 02:37:26 -06:00
wangyu-
2e1d4f001d Merge branch 'master' of https://github.com/wangyu-/udp2raw-tunnel 2017-11-09 02:20:44 -06:00
wangyu-
ae82925a74 tune parameter 2017-11-09 02:18:22 -06:00
wangyu-
f953d6d702 Update README.zh-cn.md 2017-11-08 16:03:34 -08:00
wangyu-
9e522f79b8 Update README.zh-cn.md 2017-11-08 15:59:04 -08:00
wangyu-
72c6240716 Update README.md 2017-11-08 15:55:41 -08:00
wangyu-
aac9453518 new option hb-mode 2017-11-07 01:07:32 -06:00
wangyu-
b24784b26c changed parameter 2017-11-06 03:15:05 -06:00
wangyu-
5660eed366 increase heart beat length 2017-11-06 03:00:16 -06:00
wangyu-
4c92c29948 added version.txt into makefile 2017-11-03 01:04:59 -05:00
wangyu-
cadb142455 added missing files 2017-11-02 19:49:04 -05:00
wangyu-
fcb418f5ea Merge branch 'master' of https://github.com/wangyu-/udp2raw-tunnel 2017-11-01 23:01:23 -05:00
wangyu-
63eb7f1f7f fixed bug of last few commit, and fixed a bug of bind error 2017-11-01 08:25:50 -05:00
wangyu-
66b2bb87c5 Update README.md 2017-10-30 20:25:17 -07:00
wangyu-
6b27f8624d Update README.md 2017-10-30 20:24:53 -07:00
wangyu-
ce7b89f6b6 Update README.md 2017-10-30 20:22:42 -07:00
wangyu-
a0bfa86699 Update README.zh-cn.md 2017-10-30 08:42:38 -07:00
wangyu-
e332cabfed Update README.zh-cn.md 2017-10-30 08:42:21 -07:00
wangyu-
9798bf496a Update README.zh-cn.md 2017-10-30 08:41:54 -07:00
wangyu-
7aa4b8745e trival 2017-10-30 08:59:47 -05:00
wangyu-
ea6a41ebb3 more fix 2017-10-30 08:37:53 -05:00
wangyu-
77ba1161f5 fix timer of fd64 2017-10-30 08:19:21 -05:00
wangyu-
7858c4d832 fixed some bug of last commit 2017-10-30 08:02:23 -05:00
wangyu-
71152ffbe3 added an assert 2017-10-30 07:29:40 -05:00
wangyu-
b06e979dc8 Merge branch 'master' of https://github.com/wangyu-/udp2raw-tunnel 2017-10-30 07:24:26 -05:00
wangyu-
5300f98b0a Update README.md 2017-10-25 21:10:26 -07:00
wangyu-
063d133463 Update README.md 2017-10-25 21:09:59 -07:00
wangyu-
4c88df9c0e Add files via upload 2017-10-26 12:09:09 +08:00
wangyu-
52cb20ec20 Update README.md 2017-10-25 21:04:18 -07:00
wangyu-
7aede9edd0 Update README.md 2017-10-25 21:00:10 -07:00
18 changed files with 28 additions and 55 deletions

View File

@@ -1,6 +0,0 @@
For English speaking user
https://github.com/wangyu-/UDPspeeder/wiki/Issue-Guide
中文用户请看:
https://github.com/wangyu-/UDPspeeder/wiki/发Issue前请看
(否则Issue可能被忽略或被直接关掉)

View File

@@ -3,9 +3,11 @@
A Tunnel which turns UDP Traffic into Encrypted FakeTCP/UDP/ICMP Traffic by using Raw Socket, helps you Bypass UDP FireWalls(or Unstable UDP Environment). It can defend Replay-Attack and supports Multiplexing. It also acts as a Connection Stabilizer.
When used alone,udp2raw tunnels only UDP traffic. Nevertheless,if you used udp2raw + any UDP-based VPN together,you can tunnel any traffic(include TCP/UDP/ICMP),currently OpenVPN/L2TP/ShadowVPN and [tinyFecVPN](https://github.com/wangyu-/tinyFecVPN) are confirmed to be supported.
![image0](images/image0.PNG)
When used alone,udp2raw tunnels only UDP traffic. Nevertheless,if you used udp2raw + any UDP-based VPN together,you can tunnel any traffic(include TCP/UDP/ICMP),currently OpenVPN/L2TP/ShadowVPN and [tinyFecVPN](https://github.com/wangyu-/tinyFecVPN) are confirmed to be supported.
or
![image_vpn](images/udp2rawopenvpn.PNG)

View File

@@ -16,7 +16,7 @@ u64_t get_current_time()
{
timespec tmp_time;
clock_gettime(CLOCK_MONOTONIC, &tmp_time);
return ((u64_t)tmp_time.tv_sec)*1000llu+((u64_t)tmp_time.tv_nsec)/(1000*1000llu);
return tmp_time.tv_sec*1000+tmp_time.tv_nsec/(1000*1000l);
}
u64_t pack_u64(u32_t a,u32_t b)

View File

@@ -1,5 +1,5 @@
# Udp2raw-tunnel
![image2](/images/image0.PNG)
Udp2raw-tunnel
![image2](/images/image2.PNG)
udp2raw tunnel通过raw socket给UDP包加上TCP或ICMP header进而绕过UDP屏蔽或QoS或在UDP不稳定的环境下提升稳定性。可以有效防止在使用kcptun或者finalspeed的情况下udp端口被运营商限速。
支持心跳保活、自动重连,重连后会恢复上次连接,在底层掉线的情况下可以保持上层不掉线。同时有加密、防重放攻击、信道复用的功能。
@@ -20,17 +20,7 @@ https://github.com/wangyu-/UDPspeeder
# 支持的平台
Linux主机有root权限。可以是PC、android手机/平板、openwrt路由器、树莓派。主机上最好安装了iptables命令(apt/yum很容易安装)。
Release中提供了`amd64``x86``arm``mips_be``mips_le`的预编译binary.
##### 对于windows和mac用户
在虚拟机中可以稳定使用udp2raw跑在Linux里其他应用照常跑在window里确保虚拟机网卡工作在桥接模式。可以使用[这个](https://github.com/wangyu-/udp2raw-tunnel/releases/download/20171108.0/lede-17.01.2-x86_virtual_machine_image.zip)虚拟机镜像大小只有7.5mb免去在虚拟机里装系统的麻烦虚拟机自带ssh server可以scp拷贝文件可以ssh进去可以复制粘贴root密码123456。
如果你的网络不允许桥接也是有办法用的具体方法请看wiki。
##### 对于ios和游戏主机用户
可以把udp2raw运行在局域网的其他机器上。最好的办法是买个能刷OpenWrt/LEDE/梅林的路由器把udp2raw运行在路由器上。
对于windows和mac用户在虚拟机中可以稳定使用udp2raw跑在Linux里其他应用照常跑在window里确保虚拟机网卡工作在桥接模式。可以使用[这个](https://github.com/wangyu-/udp2raw-tunnel/releases/download/20171108.0/lede-17.01.2-x86_virtual_machine_image.zip)虚拟机镜像大小只有7.5mb免去在虚拟机里装系统的麻烦虚拟机自带ssh server可以scp拷贝文件可以ssh进去可以复制粘贴root密码123456。
# 功能特性
### 把udp流量伪装成tcp /icmp
@@ -60,9 +50,9 @@ NAT 穿透 tcp icmp udp模式都支持nat穿透。
支持Openvz配合finalspeed使用可以在openvz上用tcp模式的finalspeed
支持Openwrt没有编译依赖容易编译到任何平台上。
支持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
@@ -172,14 +162,14 @@ facktcp模式并没有模拟tcp的全部。所以理论上有办法把faketcp和
### `--keep-rule`
定期主动检查iptables如果udp2raw添加的iptables规则丢了就重新添加。在一些iptables可能会被其他程序清空的情况下(比如梅林固件和openwrt的路由器)格外有用。
### `--lower-level`
大部分udp2raw不能连通的情况都是设置了不兼容的iptables造成的。--lower-level选项允许绕过本地iptables。在一些iptables不好改动的情况下尤其有效比如你用的是梅林固件iptables全是固件自己生成的
### `--fifo`
指定一个fifo(named pipe)来向运行中的程序发送命令,例如`--fifo fifo.file`
在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地址这个属于罕见的应用场景可以忽略

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 44 KiB

View File

@@ -1 +0,0 @@

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

View File

@@ -7,6 +7,8 @@
#include "encrypt.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];
@@ -227,6 +229,11 @@ int client_on_timer(conn_info_t &conn_info) //for client. called when a timer is
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)
{
conn_info.state.client_current_state=client_idle;
@@ -234,14 +241,6 @@ 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");
}
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);
if(hb_mode==0)
@@ -1196,13 +1195,13 @@ int client_event_loop()
if (nfds < 0) { //allow zero
if(errno==EINTR )
{
mylog(log_info,"epoll interrupted by signal,continue\n");
mylog(log_info,"epoll interrupted by signal\n");
//close(fifo_fd);
//myexit(0);
myexit(0);
}
else
{
mylog(log_fatal,"epoll_wait return %d,%s\n", nfds,strerror(errno));
mylog(log_fatal,"epoll_wait return %d\n", nfds);
myexit(-1);
}
}
@@ -1440,12 +1439,12 @@ int server_event_loop()
if (nfds < 0) { //allow zero
if(errno==EINTR )
{
mylog(log_info,"epoll interrupted by signal,continue\n");
//myexit(0);
mylog(log_info,"epoll interrupted by signal\n");
myexit(0);
}
else
{
mylog(log_fatal,"epoll_wait return %d,%s\n", nfds,strerror(errno));
mylog(log_fatal,"epoll_wait return %d\n", nfds);
myexit(-1);
}
}

View File

@@ -16,9 +16,6 @@
int hb_mode=1;
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;
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
@@ -155,8 +152,7 @@ void print_help()
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(" --keep-rule monitor iptables and auto re-add if necessary.implys -a\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(" --hb-len <number> length of heart-beat packet\n");
printf(" --clear clear any iptables rules added by this program.overrides everything\n");
printf(" -h,--help print this help message\n");
@@ -257,7 +253,6 @@ void process_arg(int argc, char *argv[]) //process all options
{"fifo", required_argument, 0, 1},
{"hb-mode", required_argument, 0, 1},
{"hb-len", required_argument, 0, 1},
{"mtu-warn", required_argument, 0, 1},
{NULL, 0, 0, 0}
};
@@ -612,12 +607,7 @@ void process_arg(int argc, char *argv[]) //process all options
assert(hb_len>=0&&hb_len<=1500);
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
{
mylog(log_warn,"ignored unknown long option ,option_index:%d code:<%x>\n",option_index, optopt);

3
misc.h
View File

@@ -15,7 +15,6 @@
extern int hb_mode;
extern int hb_len;
extern int mtu_warn;
const u32_t max_handshake_conn_num=10000;
const u32_t max_ready_conn_num=1000;
@@ -42,7 +41,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 uint32_t conv_timeout=180000; //ms. 120 second
const uint32_t conv_timeout=120000; //ms. 120 second
//const u32_t conv_timeout=30000; //for test
const u32_t client_conn_timeout=10000;//ms.