mirror of
https://github.com/wangyu-/udp2raw.git
synced 2025-09-15 19:54:28 +08:00
Compare commits
58 Commits
20170809.0
...
20170811.0
Author | SHA1 | Date | |
---|---|---|---|
|
2fa2666479 | ||
|
fdbf1e082f | ||
|
d502de0c7c | ||
|
8487d7c624 | ||
|
83b00e79ad | ||
|
36ed28064a | ||
|
746aefa70a | ||
|
a69cbf23da | ||
|
fc4d178657 | ||
|
ccab523ddf | ||
|
4eb72f6139 | ||
|
6296322e22 | ||
|
3a0c512e43 | ||
|
e01d7059ad | ||
|
5e6d977247 | ||
|
c08bd12ea0 | ||
|
ebdb08873a | ||
|
46b0a00b3e | ||
|
d1934dda4c | ||
|
81e599e84c | ||
|
fadf5a25c2 | ||
|
9f25a61dad | ||
|
165dc193f0 | ||
|
e732ce2a8a | ||
|
d7cae0be18 | ||
|
c1b8eb23a2 | ||
|
1bbe19cdee | ||
|
b16b37c879 | ||
|
9479c95510 | ||
|
90b1897d4a | ||
|
3fa1a99046 | ||
|
eb59012b7b | ||
|
1a2cd767c0 | ||
|
8f04c82788 | ||
|
1b9f2a1e0e | ||
|
7592729abc | ||
|
e890a6344c | ||
|
bc6358aa0a | ||
|
ed6416a30d | ||
|
9378cee8d1 | ||
|
0b3fb41f6f | ||
|
41489af1d1 | ||
|
3a1bacc11e | ||
|
06d7638c5f | ||
|
380971fe2b | ||
|
709258b260 | ||
|
c3a8305e49 | ||
|
5c08d65d91 | ||
|
6f9ab92c1d | ||
|
2f57fa6670 | ||
|
d104074328 | ||
|
7c280ab335 | ||
|
eb8567b693 | ||
|
fec382ebab | ||
|
4d319f54ff | ||
|
a58618c73c | ||
|
456da000f4 | ||
|
91e229616c |
19
CMakeLists.txt
Normal file
19
CMakeLists.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
cmake_minimum_required(VERSION 3.7)
|
||||
project(udp2raw_tunnel)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set_source_files_properties(lib/aes.c lib/md5.c PROPERTIES LANGUAGE CXX )
|
||||
|
||||
set(SOURCE_FILES
|
||||
lib/aes.c
|
||||
lib/md5.c
|
||||
common.cpp
|
||||
encrypt.cpp
|
||||
log.cpp
|
||||
main.cpp
|
||||
network.cpp
|
||||
)
|
||||
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -static")
|
||||
#set(CMAKE_LINK_LIBRARY_FLAG "-lrt")
|
||||
add_executable(udp2raw_tunnel ${SOURCE_FILES})
|
||||
target_link_libraries(udp2raw_tunnel rt)
|
114
README.md
114
README.md
@@ -1,45 +1,70 @@
|
||||
# Udp2raw-tunnel
|
||||

|
||||
|
||||
An Encrpyted,Anti-Replay,Multiplexed Udp Tunnel,tunnels udp traffic through raw socket
|
||||
An encrpyted, anti-replay, multiplexing UDP tunnel which tunnels UDP traffic with fake TCP or ICMP header using raw socket. Also acts as a connection stablizer.
|
||||
|
||||
[简体中文](/doc/README.zh-cn.md)
|
||||
### Send/Recv Udp Packet as Raw Packet with TCP header,ICMP header
|
||||
Which can help you bypass udp blocking or udp QOS or just poorly supported udp NAT behavior by some ISP. Raw packet with UDP header is also supported,in this way you can just make use of the encrpyting and anti-replay feature.
|
||||
### Encrpytion and Anti-Replay
|
||||
encrypt your traffic with aes128cbc,protects data integrity by md5 or crc32,protect replay attack with an anti-replay window smiliar to ipsec/openvpn.
|
||||
### Simulated TCP Handshake
|
||||
simulated 3-way handshake,simluated seq ack_seq. Simluated tcp options:MSS,sackOk,TS,TS_ack,wscale. Provides real-time delivery ,no tcp over tcp problem when using openvpn.
|
||||
### Connnection Failure Dectection & Recover
|
||||
Conection failure detection by hearbeat. After hearbeat timeouts,client will auto change port and re-connect.if re-connection is successful,the previous connection will be recovered,and all existed udp conversations will stay vaild.
|
||||
# Features
|
||||
### Send / Receive UDP Packet with fake headers
|
||||
Fake headers help you bypass UDP blocking, UDP QOS or improper UDP NAT behavior on some ISPs. Raw packets with UDP headers are also supported, in this mode you can just use the encrpyting,anti-replay and connection-stablize feature.
|
||||
|
||||
### Simulate TCP Handshake
|
||||
Simulates the 3-way handshake, along with seq and ack_seq. TCP options MSS, sackOk, TS, TS_ack, wscale are also simulated. Real-time delivery guaranteed, no TCP over TCP problem when using OpenVPN.
|
||||
|
||||
### Encrpytion, Anti-Replay, Anti-MITM
|
||||
* Encrypt your traffic with AES-128-CBC.
|
||||
* Protect data integrity by MD5 or CRC32.
|
||||
* Defense replay attack with an anti-replay window, smiliar to IPSec and OpenVPN.
|
||||
* Authenticate mutually, no more MITM attacks.
|
||||
|
||||
### Failure Dectection & Stablization (Connection Recovery)
|
||||
Conection failures are detected by heartbeats. If timed-out, the client will automatically change the port number and reconnect. If reconnection is successful, the previous connection will be recovered, and all existing UDP conversations will stay vaild.
|
||||
|
||||
For example, if you use UDP2RAW + OpenVPN, OpenVPN won't lose connection after any reconnect, **even if the network cable is re-plugged or the WiFi access point is changed**.
|
||||
|
||||
### Other Features
|
||||
Multiplexing ,one client supports multi udp connections,all of those traffic will share one raw connection
|
||||
* **Multiplexing** One client can handle multiple UDP connections, all of which share the same raw connection.
|
||||
|
||||
Multiple Clients Support,one server supports multiple clients.
|
||||
* **Multiple Clients** One server can have multiple clients.
|
||||
|
||||
NAT Supported,all 3 modes work in NAT environment
|
||||
* **NAT Support** All of the 3 modes work in NAT-ed environments.
|
||||
|
||||
OpenVZ Supported,tested on bandwagonhost
|
||||
* **OpenVZ Support** Tested on BandwagonHost.
|
||||
|
||||
* **OpenWRT Support** No dependencies, easy to build. Binary for ar71xx are included in release.
|
||||
|
||||
### Keywords
|
||||
* UDP QoS Bypass
|
||||
* UDP Blocking Bypass
|
||||
* OpenVPN TCP over TCP problem
|
||||
* OpenVPN over ICMP
|
||||
* UDP to ICMP tunnel
|
||||
* UDP to TCP tunnel
|
||||
* UDP over ICMP
|
||||
* UDP over TCP
|
||||
|
||||
Openwrt Supported,no dependence package,easy to compile,ar71xx binary included in release.
|
||||
### Key Words
|
||||
bypass udp qos,bypass udp blocking,openvpn tcp over tcp problem,openvpn over icmp,udp to icmp tunnel,udp to tcp tunnel,udp via icmp,udp via tcp
|
||||
# Getting Started
|
||||
### Prerequisites
|
||||
linux host,root access. if you want to use it on window,you can use VMware in bridged mode.
|
||||
A Linux host (including desktop Linux, OpenWRT router, or Raspberry PI) with root access.
|
||||
|
||||
If you want to use it on MICRO$OFT Windows, you can use VMware or Hyper-V (both bridged mode and NAT mode are supported).
|
||||
|
||||
### Installing
|
||||
download binary release from https://github.com/wangyu-/udp2raw-tunnel/releases
|
||||
Download binary release from https://github.com/wangyu-/udp2raw-tunnel/releases
|
||||
|
||||
### Running
|
||||
assume your udp is blocked or being QOS-ed or just poorly supported.assume your server ip is 44.55.66.77, you have a service listening on udp port 7777.
|
||||
```
|
||||
run at client side:
|
||||
Assume your UDP is blocked or being QOS-ed or just poorly supported. Assume your server ip is 44.55.66.77, you have a service listening on udp port 7777.
|
||||
|
||||
```bash
|
||||
# Run at client side
|
||||
./udp2raw_amd64 -c -l0.0.0.0:3333 -r44.55.66.77:4096 -a -k "passwd" --raw-mode faketcp
|
||||
|
||||
run at server side:
|
||||
# Run at server side:
|
||||
./udp2raw_amd64 -s -l0.0.0.0:4096 -r 127.0.0.1:7777 -a -k "passwd" --raw-mode faketcp
|
||||
|
||||
```
|
||||
Now,your client and server established a tunnel thorough tcp port 4096. Connecting to udp port 3333 at client side is equivalent with connecting to port 7777 at server side. No udp traffic will be exposed to outside.
|
||||
|
||||
Now,an encrypted raw tunnel has been established between client and server through TCP port 4096. Connecting to UDP port 3333 at the client side is equivalent to connecting to port 7777 at the server side. No UDP traffic will be exposed.
|
||||
|
||||
# Advanced Topic
|
||||
### Usage
|
||||
```
|
||||
@@ -77,25 +102,30 @@ other options:
|
||||
2:increase randomly, about every 3 packets (default)
|
||||
-h,--help print this help message
|
||||
```
|
||||
### iptables rule
|
||||
this programs sends packet via raw socket.In faketcp mode,Linux Kernel TCP packet processing has to be blocked by a iptables rule on both sides,otherwise Kernel will automatically send RST for unrecongized TCP packet and you will sustain from stability/peformance problem.You can use -a option to let the program automatically add/del iptables rule on start/exit.You can also use the -g option to generate iptables rule and add it manually.
|
||||
### cipher-mode and auth-mode
|
||||
Its suggested to use aes128cbc + md5 to obtain maxmized security.If you want to run the program on a router,you can try xor+simple,it can fool Packet Inspection by firewalls most time, but it cant protect you from serious attackers. Mode none is only for debug,its not suggest to set cipher-mode or auth-mode to none.
|
||||
|
||||
### IPTABLES rule
|
||||
This program sends packets via raw socket. In FakeTCP mode, Linux kernel TCP packet processing has to be blocked by a iptables rule on both sides, otherwise the kernel will automatically send RST for an unrecongized TCP packet and you will sustain from stability / peformance problems. You can use `-a` option to let the program automatically add / delete iptables rule on start / exit. You can also use the -g option to generate iptables rule and add it manually.
|
||||
|
||||
### `cipher-mode` and `auth-mode`
|
||||
It is suggested to use AES-128-CBC + MD5 to obtain maximum security. If you want to run the program on a router, you can try XOR + simple, which can fool packet inspection by firewalls the most of time, but it cannot protect you from serious attacks. Mode none is only for debugging purpose. It is not recommended to set the cipher-mode or auth-mode to none.
|
||||
|
||||
### seq-mode
|
||||
the faketcp mode doest not behave 100% like a real tcp connection.ISP may be able to distinguish the simulated tcp traffic from real tcp traffic(though its costly). seq-mode can help you changed the seq increase behavior a bit. If you experienced problems,try to change the value.
|
||||
The FakeTCP mode does not behave 100% like a real tcp connection. ISPs may be able to distinguish the simulated tcp traffic from the real TCP traffic (though it's costly). seq-mode can help you change the seq increase behavior slightly. If you experience any problems, try to change the value.
|
||||
|
||||
# Peformance Test
|
||||
#### test method:
|
||||
iperf3 tcp via openvpn + udp2raw
|
||||
(iperf3 udp mode is not used bc of bug mentioned in this issue: https://github.com/esnet/iperf/issues/296 ,instead,we turn iperf3 's tcp traffic into udp by using openvpn,to test udp2raw 's peformance. Read [Application](https://github.com/wangyu-/udp2raw-tunnel#application) for detail )
|
||||
#### Test method:
|
||||
iperf3 TCP via OpenVPN + udp2raw
|
||||
(iperf3 UDP mode is not used because of a bug mentioned in this issue: https://github.com/esnet/iperf/issues/296 . Instead, we package the TCP traffic into UDP by OpenVPN to test the performance. Read [Application](https://github.com/wangyu-/udp2raw-tunnel#application) for details.
|
||||
|
||||
#### iperf3 command:
|
||||
```
|
||||
iperf3 -c 10.222.2.1 -P40
|
||||
iperf3 -c 10.222.2.1 -P40 -R
|
||||
```
|
||||
#### client host
|
||||
vultr $2.5/monthly plan(single core 2.4ghz cpu,512m ram,location:Tokyo,Japan),
|
||||
#### server host
|
||||
bandwagonhost $3.99/annually(single core 2.0ghz cpu,128m ram,location:Los Angeles,USA)
|
||||
#### Environments
|
||||
* **Client** Vultr $2.5/monthly plan (single core 2.4GHz cpu, 512MB RAM, Tokyo, Japan)
|
||||
* **Server** BandwagonHost $3.99/annually plan (single core 2.0GHz cpu, 128MB RAM, Los Angeles, USA)
|
||||
|
||||
### Test1
|
||||
raw_mode: faketcp cipher_mode: xor auth_mode: simple
|
||||
|
||||
@@ -120,12 +150,15 @@ raw_mode: faketcp cipher_mode: aes128cbc auth_mode: md5
|
||||
3. openvpn over icmp also becomes a choice
|
||||
|
||||
more details at [openvpn+udp2raw_guide](/doc/openvpn_guide.md)
|
||||
### tunneling kcptun
|
||||
make kcptun support tcp mode.
|
||||
### speed-up tcp connection via raw traffic by using udp2raw+kcptun
|
||||
kcptun is a tcp connection speed-up program,it speeds-up tcp connection by using kcp protocol on-top of udp.by using udp2raw,you can use kcptun while udp is QoSed or blocked.
|
||||
(kcptun, https://github.com/xtaci/kcptun)
|
||||
|
||||
### tunneling finalspeed
|
||||
finalspeed 's tcp mode doesnt work on openvz VPS.you can use finalspeed 's udp mode,and tunnel udp through tcp with this tunnel.
|
||||
### speed-up tcp connection via raw traffic by using udp2raw+finalspeed
|
||||
finalspeed is a tcp connection speed-up program similiar to kcptun,it speeds-up tcp connection by using kcp protocol on-top of udp or tcp.but its tcp mode doesnt support openvz,you can bypass this problem if you use udp2raw+finalspeed together,and icmp mode also becomes avaliable.
|
||||
|
||||
# How to build
|
||||
read [build_guide](/doc/build_guide.md)
|
||||
|
||||
# Related work
|
||||
### kcptun-raw
|
||||
@@ -144,4 +177,3 @@ https://github.com/linhua55/some_kcptun_tools/tree/master/relayRawSocket
|
||||
Transparently tunnel your IP traffic through ICMP echo and reply packets.
|
||||
|
||||
https://github.com/DhavalKapil/icmptunnel
|
||||
|
||||
|
2
common.h
2
common.h
@@ -71,7 +71,7 @@ const u32_t client_retry_interval=1000;
|
||||
const u32_t server_handshake_timeout=10000;// this should be much longer than clients. client retry initially ,server retry passtively
|
||||
|
||||
const int conv_clear_ratio=10; //conv grabage collecter check 1/10 of all conv one time
|
||||
const int conn_clear_ratio=10;
|
||||
const int conn_clear_ratio=30;
|
||||
const int conv_clear_min=5;
|
||||
const int conn_clear_min=1;
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
Udp2raw-tunnel
|
||||

|
||||
加密、防重放攻击的、信道复用的udp tunnel,利用raw socket中转udp流量
|
||||
加密、防重放攻击的、信道复用的udp tunnel,利用raw socket中转udp流量.同时有心跳保活,且在断线重连后保持上层连接不掉线的功能。
|
||||
|
||||
[English](/README.md)
|
||||
|
||||
@@ -11,25 +11,24 @@ Udp2raw-tunnel
|
||||
如果你需要加速跨国网游、网页浏览,解决方案在另一个repo:
|
||||
|
||||
https://github.com/wangyu-/UDPspeeder
|
||||
# 功能特性
|
||||
### 把udp流量伪装成tcp /icmp
|
||||
用raw socket给udp包加上tcp/icmp包头,可以突破udp流量限制或Udp QOS。或者在udp nat有问题的环境下,提升稳定性。 另外也支持用raw 发udp包,这样流量不会被伪装,只会被加密。
|
||||
|
||||
### 加密 防重放攻击
|
||||
用aes128cbc加密,md5/crc32做数据完整校验。用类似ipsec/openvpn的 replay windows机制来防止重放攻击。
|
||||
|
||||
设计目标是,即使攻击者可以监听到tunnel的所有包,可以选择性丢弃tunnel的任意包,可以重放任意包;攻击者也没办法获得tunnel承载的任何数据,也没办法向tunnel的数据流中通过包构造/包重放插入任何数据。
|
||||
|
||||
### 模拟TCP3次握手
|
||||
模拟TCP3次握手,模拟seq ack过程。另外还模拟了一些tcp option:MSS,sackOk,TS,TS_ack,wscale,用来使流量看起来更像是由普通的linux tcp协议栈发送的。
|
||||
|
||||
### 连接保持,连接快速恢复,单向链路失效检测
|
||||
心跳机制检查连接是否中断,一旦心跳超时。client会立即换raw socket的端口重连,重连成功后会恢复之前中断的连接。虽然raw端的端口变了,但是udp端的所有连接都会继续有效。udp这边感觉不到raw端的重连,只会感觉到短暂断流,这跟普通的短暂丢包是类似的,不会导致上层应用重连。
|
||||
### 心跳保活、自动重连,连接快速恢复,单向链路失效检测
|
||||
心跳保活、自动重连,udp2raw重连可以恢复上次的连接,重连后上层连接继续有效,底层掉线上层不掉线。有效解决上层连接断开的问题。 (功能借鉴自[kcptun-raw](https://github.com/Chion82/kcptun-raw))(**就算你拔掉网线重插,或者重新拨号获得新ip,上层应用也不会断线**)
|
||||
|
||||
Client能用单倍的超时时间检测到单向链路的失效,不管是上行还是下行,只要有一端失效就能被client检测到。重连只需要client发起,就可以立即被server处理,不需要等到server端的连接超时后。
|
||||
Client能用单倍的超时时间检测到单向链路的失效,不管是上行还是下行,只要有一个方向失效就能被client检测到。重连只需要client发起,就可以立即被server处理,不需要等到server端的连接超时后。
|
||||
|
||||
对于有大量client的情况,对于不同client,server发送的心跳是错开时间发送的,不会因为短时间发送大量的心跳而造成拥塞和延迟抖动。
|
||||
|
||||
### 加密 防重放攻击 防中间人攻击
|
||||
用aes128cbc加密,md5/crc32做数据完整校验。用类似ipsec/openvpn的 replay windows机制来防止重放攻击。
|
||||
|
||||
设计目标是,即使攻击者可以监听到tunnel的所有包,可以选择性丢弃tunnel的任意包,可以重放任意包;攻击者也没办法获得tunnel承载的任何数据,也没办法向tunnel的数据流中通过包构造/包重放插入任何数据。client和server互相认证对方,无法被中间人攻击。
|
||||
|
||||
### 其他特性
|
||||
信道复用,client的udp端支持多个连接。
|
||||
@@ -40,9 +39,9 @@ NAT 穿透 ,tcp icmp udp模式都支持nat穿透。
|
||||
|
||||
支持Openvz,配合finalspeed使用,可以在openvz上用tcp模式的finalspeed
|
||||
|
||||
支持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
|
||||
@@ -50,7 +49,7 @@ epoll纯异步,高并发,除了回收过期连接外,所有操作的时间
|
||||
# 简明操作说明
|
||||
|
||||
### 环境要求
|
||||
Linux主机,有root权限。主机上最好安装了iptables命令(apt/yum很容易安装)。在windows和mac上可以开虚拟机(桥接模式测试可用)。
|
||||
Linux主机,有root权限。主机上最好安装了iptables命令(apt/yum很容易安装)。在windows和mac上可以开虚拟机(桥接模式和NAT模式经测试都可用)。
|
||||
|
||||
### 安装
|
||||
下载编译好的二进制文件,解压到任意目录。
|
||||
@@ -110,7 +109,7 @@ other options:
|
||||
-h,--help print this help message
|
||||
```
|
||||
### iptables 规则
|
||||
用raw收发tcp包本质上绕过了linux内核的tcp协议栈。linux碰到raw socket发来的包会不认识,如果一直收到不认识的包,会回复大量RST,造成不稳定或性能问题。所以强烈建议添加iptables规则屏蔽Linux内核的对指定端口的处理。用-a选项,udp2raw会在启动的时候自动帮你加上Iptables规则,退出的时候再自动删掉。如果你不信任-a选项的可靠性,可以用-g选项来生成相应的Ip规则再自己手动添加。
|
||||
用raw收发tcp包本质上绕过了linux内核的tcp协议栈。linux碰到raw socket发来的包会不认识,如果一直收到不认识的包,会回复大量RST,造成不稳定或性能问题。所以强烈建议添加iptables规则屏蔽Linux内核的对指定端口的处理。用-a选项,udp2raw会在启动的时候自动帮你加上Iptables规则,退出的时候再自动删掉。如果长期使用,可以用-g选项来生成相应的Iptables规则再自己手动添加,这样规则不会在udp2raw退出时被删掉,可以避免停掉udp2raw后内核向对端回复RST。
|
||||
|
||||
用raw收发udp包也类似,只是内核回复的是icmp unreachable。而用raw 收发icmp,内核会自动回复icmp echo。都需要相应的iptables规则。
|
||||
### cipher-mode 和 auth-mode
|
||||
@@ -154,6 +153,8 @@ raw_mode: faketcp cipher_mode: aes128cbc auth_mode: md5
|
||||
[udp2raw+kcptun step_by_step教程](kcptun_step_by_step.md)
|
||||
### 中转 finalspeed
|
||||
[udp2raw+finalspeed step_by_step教程](finalspeed_step_by_step.md)
|
||||
# 如何自己编译
|
||||
[编译教程](build_guide.zh-cn.md)
|
||||
# 相关repo
|
||||
### kcptun-raw
|
||||
this project was inspired by kcptun-raw,which modified kcptun to support tcp mode.
|
||||
|
74
doc/build_guide.md
Normal file
74
doc/build_guide.md
Normal file
@@ -0,0 +1,74 @@
|
||||
# udp2raw build guide
|
||||
|
||||
the guide on how to build udp2raw to you own platform
|
||||
|
||||
## linux platform which supports local compile
|
||||
such as PC,raspberry pi
|
||||
|
||||
##### install git
|
||||
run on debian/ubuntun:
|
||||
```
|
||||
sudo apt-get install git
|
||||
```
|
||||
run on redhat/centos:
|
||||
```
|
||||
sudo yum install git
|
||||
```
|
||||
##### clone git code
|
||||
|
||||
run in any dir:
|
||||
|
||||
```
|
||||
git clone https://github.com/wangyu-/udp2raw-tunnel.git
|
||||
cd udp2raw-tunnel
|
||||
```
|
||||
|
||||
##### install compile tool
|
||||
run on debian/ubuntun:
|
||||
```
|
||||
sudo apt-get install build-essential
|
||||
```
|
||||
|
||||
run on redhat/centos:
|
||||
```
|
||||
sudo yum groupinstall 'Development Tools'
|
||||
```
|
||||
|
||||
run 'make',compilation done. the udp2raw file is the just compiled binary
|
||||
|
||||
## platform which needs cross-compile
|
||||
such as openwrt router,run following instructions on your PC
|
||||
|
||||
##### install git
|
||||
run on debian/ubuntun:
|
||||
```
|
||||
sudo apt-get install git
|
||||
```
|
||||
run on redhat/centos:
|
||||
```
|
||||
sudo yum install git
|
||||
```
|
||||
|
||||
##### download cross compile tool chain
|
||||
|
||||
find it on downloads.openwrt.org according to your openwrt version and cpu model.
|
||||
|
||||
for example, my tplink wdr4310 runs chaos_calmer 15.05,its with ar71xx cpu,download the following package.
|
||||
|
||||
```
|
||||
http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/OpenWrt-SDK-15.05-ar71xx-generic_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64.tar.bz2
|
||||
```
|
||||
unzip it to any dir,such as :/home/wangyu/OpenWrt-SDK-ar71xx-for-linux-x86_64-gcc-4.8-linaro_uClibc-0.9.33.2
|
||||
|
||||
cd into staging_dir ,toolchain-xxxxx ,bin .find the soft link with g++ suffix. in my case ,its mips-openwrt-linux-g++ ,check for its full path:
|
||||
|
||||
```
|
||||
/home/wangyu/Desktop/OpenWrt-SDK-15.05-ar71xx-generic_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-g++
|
||||
```
|
||||
##### compile
|
||||
modify first line of makefile to:
|
||||
```
|
||||
cc_cross=/home/wangyu/Desktop/OpenWrt-SDK-15.05-ar71xx-generic_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-g++
|
||||
```
|
||||
|
||||
run 'make cross',the just generated udp2raw_cross is the binary,compile done. copy it to your router to run.
|
72
doc/build_guide.zh-cn.md
Normal file
72
doc/build_guide.zh-cn.md
Normal file
@@ -0,0 +1,72 @@
|
||||
# udp2raw编译方法
|
||||
本文演示怎么把udp2raw编译到自己所需的平台。
|
||||
|
||||
## 可以本地编译的linux平台
|
||||
比如电脑、树莓派
|
||||
|
||||
##### 首先安装git
|
||||
debian/ubuntun执行:
|
||||
```
|
||||
sudo apt-get install git
|
||||
```
|
||||
redhat/centos执行:
|
||||
```
|
||||
sudo yum install git
|
||||
```
|
||||
##### 用git把源码clone至本地
|
||||
|
||||
在任意目录执行:
|
||||
|
||||
```
|
||||
git clone https://github.com/wangyu-/udp2raw-tunnel.git
|
||||
cd udp2raw-tunnel
|
||||
```
|
||||
|
||||
##### 安装g++ make 等工具
|
||||
debian/ubuntun执行:
|
||||
```
|
||||
sudo apt-get install build-essential
|
||||
```
|
||||
|
||||
redhat/centos执行:
|
||||
```
|
||||
sudo yum groupinstall 'Development Tools'
|
||||
```
|
||||
|
||||
然后运行make,编译完成。 生成的udp2raw就是编译好的bianry。
|
||||
|
||||
## 需要交叉编译的平台
|
||||
比如各种openwrt路由器
|
||||
|
||||
##### 首先安装git
|
||||
debian/ubuntun执行:
|
||||
```
|
||||
sudo apt-get install git
|
||||
```
|
||||
redhat/centos执行:
|
||||
```
|
||||
sudo yum install git
|
||||
```
|
||||
|
||||
##### 下载安装交叉编译工具包
|
||||
去downloads.openwrt.org上找到自己的openwrt版本和cpu型号对应的SDK。通常openwrt版本号不一样也问题不大,最主要是cpu型号。
|
||||
|
||||
比如我的tplink wdr4310运行的是chaos_calmer 15.05,ar71xx cpu,应该下载这个包:
|
||||
|
||||
```
|
||||
http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/OpenWrt-SDK-15.05-ar71xx-generic_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64.tar.bz2
|
||||
```
|
||||
解压到本地任意目录,比如:/home/wangyu/OpenWrt-SDK-ar71xx-for-linux-x86_64-gcc-4.8-linaro_uClibc-0.9.33.2
|
||||
|
||||
让后依次进入,staging_dir ,toolchain-xxxxx ,bin 目录,找到后缀是g++的软链,比如我的是mips-openwrt-linux-g++ ,记下这个文件的完整路径:
|
||||
|
||||
```
|
||||
/home/wangyu/Desktop/OpenWrt-SDK-15.05-ar71xx-generic_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-g++
|
||||
```
|
||||
##### 编译
|
||||
把makefile的第一行 cross_cc=后面的内容改成你刚才记下的完整路径:
|
||||
```
|
||||
cc_cross=/home/wangyu/Desktop/OpenWrt-SDK-15.05-ar71xx-generic_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-g++
|
||||
```
|
||||
|
||||
执行make cross,目录下生成udp2raw_cross文件。编译完成。
|
@@ -1,7 +1,7 @@
|
||||
# udp2raw+kcptun 加速tcp流量 Step by Step 教程
|
||||

|
||||
|
||||
本教程会一步一步演示用udp2raw+kcptun加速SSH流量的过程。加速任何其他tcp流量也一样。
|
||||
本教程会一步一步演示用udp2raw+kcptun加速SSH流量的过程。加速任何其他tcp流量也一样,包括ss;本文避免涉及科学上网,所以演示ssh。
|
||||
|
||||
### 环境要求
|
||||
两边的主机都是linux,有root权限。 可以是openwrt路由器或树莓派,windows上桥接模式的虚拟机也可用
|
||||
|
@@ -18,6 +18,9 @@ assume server ip is 45.66.77.88
|
||||
|
||||
#### client side config
|
||||
```
|
||||
client
|
||||
dev tun100
|
||||
proto udp
|
||||
|
||||
remote 127.0.0.1 3333
|
||||
resolv-retry infinite
|
||||
|
@@ -1,11 +1,11 @@
|
||||
#include <lib/aes.h>
|
||||
#include <lib/md5.h>
|
||||
#include "lib/aes.h"
|
||||
#include "lib/md5.h"
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <encrypt.h>
|
||||
#include <common.h>
|
||||
#include "encrypt.h"
|
||||
#include "common.h"
|
||||
#include "log.h"
|
||||
|
||||
//static uint64_t seq=1;
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 37 KiB |
1
images/speedtest/111
Normal file
1
images/speedtest/111
Normal file
@@ -0,0 +1 @@
|
||||
|
BIN
images/speedtest/Capture.PNG
Normal file
BIN
images/speedtest/Capture.PNG
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.0 KiB |
BIN
images/speedtest/Capture2.PNG
Normal file
BIN
images/speedtest/Capture2.PNG
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.1 KiB |
2
log.h
2
log.h
@@ -44,7 +44,7 @@
|
||||
|
||||
#include <sys/timerfd.h>
|
||||
#include <set>
|
||||
#include <encrypt.h>
|
||||
#include "encrypt.h"
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
|
12
makefile
12
makefile
@@ -1,10 +1,10 @@
|
||||
ccmips=mips-openwrt-linux-g++
|
||||
cc_cross=/home/wangyu/OpenWrt-SDK-ar71xx-for-linux-x86_64-gcc-4.8-linaro_uClibc-0.9.33.2/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-g++
|
||||
FLAGS=-Wall -Wextra -Wno-unused-variable -Wno-unused-parameter
|
||||
FLAGS2= -O3
|
||||
all:
|
||||
sudo killall udp2raw||true
|
||||
sleep 0.2
|
||||
g++ main.cpp -o udp2raw -static -ggdb -I. lib/aes.c lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp -lrt -std=c++11 ${FLAGS} ${FLAGS2}
|
||||
gcc main.cpp -o udp2raw -static -ggdb -I. lib/aes.c lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp -lrt -std=c++11 ${FLAGS} ${FLAGS2}
|
||||
# ${ccmips} main.cpp -o udp2raw_ar71xx -lrt -I. lib/aes.c lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp -std=c++11 ${FLAGS} ${FLAGS2}
|
||||
fast:
|
||||
sudo killall udp2raw||true
|
||||
@@ -14,10 +14,16 @@ fast:
|
||||
|
||||
debug:
|
||||
g++ main.cpp -o udp2raw -static -ggdb -I. -Ilib lib/aes.c lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp -lrt -std=c++11 ${FLAGS} -Wformat-nonliteral -D MY_DEBUG
|
||||
cross:
|
||||
${cc_cross} main.cpp -o udp2raw_ar71xx -lrt -I. lib/aes.c lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp -std=c++11 ${FLAGS} ${FLAGS2}
|
||||
cross2:
|
||||
${cc_cross} main.cpp -o udp2raw_ar71xx -lrt -I. lib/aes.c lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp -std=c++11 ${FLAGS} -static -lgcc_eh -O3
|
||||
cross3:
|
||||
${cc_cross} main.cpp -o udp2raw_ar71xx -lrt -I. lib/aes.c lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp -std=c++11 ${FLAGS} -static -lgcc_eh
|
||||
|
||||
release:
|
||||
g++ main.cpp -o udp2raw_amd64 -static -ggdb -I. lib/aes.c lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp -lrt -std=c++11 ${FLAGS} ${FLAGS2}
|
||||
g++ main.cpp -o udp2raw_x86 -static -ggdb -I. lib/aes.c lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp -lrt -std=c++11 ${FLAGS} ${FLAGS2} -m32
|
||||
${ccmips} main.cpp -o udp2raw_ar71xx -lrt -I. lib/aes.c lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp -std=c++11 ${FLAGS} ${FLAGS2}
|
||||
${cc_cross} main.cpp -o udp2raw_ar71xx -lrt -I. lib/aes.c lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp -std=c++11 ${FLAGS} -static -lgcc_eh -O3
|
||||
tar -zcvf udp2raw_binaries.tar.gz udp2raw_amd64 udp2raw_x86 udp2raw_ar71xx
|
||||
|
||||
|
Reference in New Issue
Block a user