Code Monkey home page Code Monkey logo

kcptun-raw's Introduction

kcptun-raw

为缓解部分ISP对UDP断流的问题,通过伪造TCP报文,实现了简化版的 kcptun
客户端和服务端进程的直接通信方式为带伪TCP报头的IP packet,通过raw socket实现,需要通过iptables绕过内核协议栈。

Inspired by linhua55/some_kcptun_tools/relayRawSocket .

Features

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

Usage

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

$ make
# ./server TARGET_IP TARGET_PORT SERVER_IP SERVER_PORT [--key 16_BYTES_KEY] [--mode MODE] [--noseq]
# ./client SERVER_IP SERVER_PORT LOCAL_IP LISTEN_PORT [--key 16_BYTES_KEY] [--mode MODE] [--noseq]

Example:
108.0.0.1替换为服务器IP,192.168.1.100替换为客户端IP(通常是路由器分配的内网IP,不能使用127.0.0.1
服务端:

# iptables -A INPUT -p tcp --dport 888 -j DROP
# ./server 127.0.0.1 8388 108.0.0.1 888 --mode fast2

客户端:

# iptables -A INPUT -p tcp -s 108.0.0.1 --sport 888 -j DROP
# ./client 108.0.0.1 888 192.168.1.100 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!

分层示意图

kcptun-raw's People

Contributors

chion82 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.