• Stars
    star
    416
  • Rank 103,443 (Top 3 %)
  • Language
    C
  • License
    GNU General Publi...
  • Created over 7 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Kcptun with raw socket and fake TCP headers.

kcptun-raw

为缓解部分ISP对UDP断流的问题,通过伪造TCP报文,实现了简化版的 kcptun
kcp的下层通信方式是带伪TCP报头的packet,通过raw socket实现,需要通过iptables绕过内核协议栈。

Inspired by linhua55/some_kcptun_tools/relayRawSocket .

Features

  • 模拟TCP三次握手、动态seq/ack(有时需要关闭),以适应各种ISP环境。
  • 两层心跳保活、快速恢复、更改随机端口重连,不容易卡死。
  • AES_CFB128加密帧。
  • 取消了FEC,丢包处理策略直接由kcp负责。
  • 请注意一个服务端进程对应一个客户端进程,如需建立多隧道或多客户端,请换个端口运行多个服务端进程。
  • 暂时仅支持linux,可配置虚拟机并让真机连接至虚拟机。

Updates

  • 2017.9.7 增加自动判定发包源地址。
    • 客户端:LOCAL_IP参数变更为LISTEN_IP,作用变更为TCP监听绑定IP,可以使用0.0.0.0127.0.0.1
    • 服务端:若指定SERVER_IP0.0.0.0,则自动获取发包源地址;否则使用手动配置的IP作为发包源地址。
  • 2017.9.5 引入内核态过滤器(BPF),提高收包性能
  • 2017.8 跨大小端支持,兼容ARM OpenWRT设备

Compilation

编译依赖:libev-devel, openssl-devel, automake, autoconf

$ ./autogen.sh
$ ./configure
$ make
$ sudo make install

Openwrt编译指南:

依赖准备:

$ cd OpenWRT-SDK-XXX
$ scripts/feeds update
$ scripts/feeds install libev
$ make menuconfig #勾选Libraries->libev
$ make V=99

交叉编译: 请参考 Cross Compile
以ar71xx 15.05.1 SDK为例:

$ export PATH=$PATH:(your toolchain/bin directory here)
$ export STAGING_DIR=(your staging_dir directory here)
$ cd kcptun-raw
$ ./autogen.sh
$ ./configure --build=architecture-unknown-linux-gnu \
--host=mips-openwrt-linux-uclibc \
CFLAGS="-I${STAGING_DIR}/target-mips_34kc_uClibc-0.9.33.2/usr/include" \
LDFLAGS="-L${STAGING_DIR}/target-mips_34kc_uClibc-0.9.33.2/usr/lib"
$ make

编译产出binary: src/kcpraw_client , src/kcpraw_server

Usage

服务端:

# iptables -A INPUT -p tcp --dport SERVER_PORT -j DROP
# kcpraw_server TARGET_IP TARGET_PORT SERVER_IP SERVER_PORT [--key 16_BYTES_KEY] [--mode MODE] [--noseq]

客户端:

# iptables -A INPUT -p tcp -s SERVER_IP --sport LISTEN_PORT -j DROP
# kcpraw_client SERVER_IP SERVER_PORT LISTEN_IP LISTEN_PORT [--key 16_BYTES_KEY] [--mode MODE] [--noseq]

示例:

108.0.0.1替换为服务器IP 服务端:

# iptables -A INPUT -p tcp --dport 888 -j DROP
# kcpraw_server 127.0.0.1 8388 0.0.0.0 888 --mode fast2

客户端:

# iptables -A INPUT -p tcp -s 108.0.0.1 --sport 888 -j DROP
# kcpraw_client 108.0.0.1 888 0.0.0.0 8388 --mode fast2
$ sslocal -s 127.0.0.1 -p 8388 -k YOUR_SS_KEY

如果客户端log中有大量Re-init fake TCP connection并且频繁断流,请尝试在客户端和服务端的命令都添加--noseq参数。

可选参数说明:

  • [--mode MODE] 加速模式,取值为normal/fast/fast2/fast3。默认为fast3
  • [--noseq] 如果添加该参数,则取消伪TCP头的seq/ack自增,可避免部分ISP环境下的断流情况。
  • [--key 16_BYTES_KEY] AES128密钥,长度必须为16字节。默认为it is a secrect!
  • [--nobpf] 禁用伯克利包过滤(BPF)模式。

分层示意图

More Repositories

1

WeChatMomentStat-Android

Get your WeChat Moment statistics and export Moments to JSON. 微信朋友圈数据统计、导出工具
Java
980
star
2

hello-old-driver

お兄ちゃん大好き(琉璃神社爬虫脚本)
Python
629
star
3

netfilter-full-cone-nat

A kernel module to turn MASQUERADE into full cone SNAT
C
426
star
4

WeChatMomentExport

Xposed module to export WeChat moments data to JSON(微信朋友圈数据导出Xposed模块)
Java
330
star
5

native-base-web

NativeBase for React Native Web. The missing piece of RN4WEB.
JavaScript
73
star
6

WeChatMomentStat

微信朋友圈简单数据分析脚本,配合WeChatMomentExport1.0使用(仅支持1.0的导出JSON)
Python
68
star
7

ASCII_bad_apple

ASCII art video of Bad Apple
Python
62
star
8

redux-wait-for-action

Redux middleware to make store.dispatch() return a promise and wait for another action.
JavaScript
55
star
9

react-native-web-extended

Extended version of react-native-web
JavaScript
25
star
10

xunlei_share

[失效]迅雷离线地址获取工具CLI版
Python
17
star
11

PixivHack

A python script to crawl and fetch illustrations from Pixiv. (P站爬图脚本)
Python
15
star
12

ChionLab

Source of ChionLab. Powered by Hexo
CSS
13
star
13

rnweb-native-base-starter

react-native-web + native-base-web starter kit (Boilerplate)
JavaScript
12
star
14

teaching-feeling-web

JavaScript
9
star
15

mwan3-traffic

Patch for mwan3 with realtime interface traffic monitor.
Shell
8
star
16

tcp-chain

A scalable TCP hook/proxy framework
C
6
star
17

react-redux-universal-minimal

Minimal starter kit (boilerplate) for universal (isomorphic) React apps.
JavaScript
6
star
18

NodeJS_midway_sample

A NodeJS midway sample project.
JavaScript
5
star
19

soft-router

Arch Linux下用于软路由的轻量级策略路由脚本
Shell
5
star
20

guapi-lu-cat

瓜皮撸猫,你身边的撸猫神器
4
star
21

Chion82.github.io

Chion82的未来道具研究所!
HTML
4
star
22

bilibili_accelerator

A Chrome extension to accelerate video loading on Bilibili
JavaScript
4
star
23

netfilter-name-set

dynamic domain name match extension for iptables by DNS hooks. WIP.
C
4
star
24

BadMine

有屏幕的地方就有Bad Apple——那么这次是XP的扫雷
C++
3
star
25

Unionpay_PHP_API

Unionpay PHP API is a simple and easy-to-use interface to implement web-based Unionpay online payment modules written in PHP.
PHP
2
star
26

163_music_cracker

[已失效]网易云音乐网页版 取消版权限制 自动选择高音质 chrome插件
JavaScript
1
star
27

native-base-web-example

Component demo app with react-native-web-extended and native-base-web.
JavaScript
1
star
28

plugin-weibo-postman

Poi插件 微博直播出击战绩和建造出货数据
JavaScript
1
star