百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
H

hev-socks5-tunnel

> 数据库
开源

一个轻量级、快速且可靠的 tun2socks

1.9K stars0 点赞2 次浏览
访问官网GitHub

工具介绍

一个轻量级、快速且可靠的 tun2socks

HevSocks5Tunnel

A simple, lightweight tunnel over Socks5 proxy (tun2socks).

Features

  • IPv4/IPv6. (dual stack)
  • Redirect TCP connections.
  • Redirect UDP packets. (Fullcone NAT, UDP-in-UDP and UDP-in-TCP [^1])
  • Optional local ICMP Echo (ping) replies.
  • Linux/Android/FreeBSD/macOS/iOS/Windows.

Benchmarks

See here for more details.

Speed

CPU usage

Memory usage

How to Build

Unix

bash
git clone --recursive https://github.com/heiher/hev-socks5-tunnel
cd hev-socks5-tunnel
make

Android

bash
mkdir hev-socks5-tunnel
cd hev-socks5-tunnel
git clone --recursive https://github.com/heiher/hev-socks5-tunnel jni
ndk-build

iOS and macOS

bash
git clone --recursive https://github.com/heiher/hev-socks5-tunnel
cd hev-socks5-tunnel
# will generate HevSocks5Tunnel.xcframework
./build-apple.sh

Windows (MSYS2)

bash
export MSYS=winsymlinks:native
git clone --recursive https://github.com/heiher/hev-socks5-tunnel
cd hev-socks5-tunnel
make

Library

bash
git clone --recursive https://github.com/heiher/hev-socks5-tunnel
cd hev-socks5-tunnel

# Static library
make static

# Shared library
make shared

How to Use

Config

…

Run

Linux

bash
# Set socks5.mark = 438
bin/hev-socks5-tunnel conf/main.yml

# Disable reverse path filter
sudo sysctl -w net.ipv4.conf.all.rp_filter=0
sudo sysctl -w net.ipv4.conf.tun0.rp_filter=0

# Bypass upstream socks5 server
sudo ip rule add fwmark 438 lookup main pref 10
sudo ip -6 rule add fwmark 438 lookup main pref 10

# Route others
sudo ip route add default dev tun0 table 20
sudo ip rule add lookup 20 pref 20
sudo ip -6 route add default dev tun0 table 20
sudo ip -6 rule add lookup 20 pref 20

FreeBSD/macOS

bash
# Bypass upstream socks5 server
# 10.0.0.1: socks5 server
# 10.0.2.2: default gateway
sudo route add -net 10.0.0.1/32 10.0.2.2

# Route others
sudo route change -inet default -interface tun0
sudo route change -inet6 default -interface tun0

Windows

bash
# Bypass upstream socks5 server
# 10.0.0.1: socks5 server
# 10.0.2.2: default gateway
route add 10.0.0.1/32 10.0.2.2

# Route others
route change 0.0.0.0/0 0.0.0.0 if tun-index
route change ::/0 :: if tun-index

OpenWrt 24.10+

Repo: https://github.com/openwrt/packages/tree/master/net/hev-socks5-tunnel

bash
# Install package
opkg install hev-socks5-tunnel

# Edit /etc/config/hev-socks5-tunnel

# Restart service
/etc/init.d/hev-socks5-tunnel restart

Low memory usage

On low-memory systems like iOS, reducing the size of the TCP buffer and task stack, as well as limiting the maximum session count, can help prevent out-of-memory issues.

yaml
misc:
  # task stack size (bytes)
  task-stack-size: 24576 # 20480 + tcp-buffer-size
  # tcp buffer size (bytes)
  tcp-buffer-size: 4096
  # maximum session count
  max-session-count: 1200

Docker Compose

…

You can also set the route rules with multiple network segments like:

yaml
    environment:
      IPV4_INCLUDED_ROUTES: 10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
      IPV4_EXCLUDED_ROUTES: |-
        a.b.c.d/24
        a.b.c.f/24

API

C

…

Java

java
public class TProxyService {
    private static native boolean TProxyStartService(String config_path, int fd);
    private static native boolean TProxyStopService();
    private static native boolean TProxyIsRunning();
    private static native long[] TProxyGetStats();

    static {
        System.loadLibrary("hev-socks5-tunnel");
    }
}

Kotlin

kotlin
object TProxyService {
    private external fun TProxyStartService(config_path: String, fd: Int): Boolean
    private external fun TProxyStopService(): Boolean
    private external fun TProxyIsRunning(): Boolean
    private external fun TProxyGetStats(): LongArray

    init {
        System.loadLibrary("hev-socks5-tunnel")
    }
}

Allow overriding the package and class names in Application.mk[^2].

makefile
APP_CFLAGS := -DPKGNAME=hev/sockstun -DCLSNAME=TProxyService

Prebuilt Android AAR

The Android CI job also produces an AAR (hev-socks5-tunnel.aar, containing all four ABIs) built with the default JNI contract — no PKGNAME/CLSNAME overrides — so its natives register to hev.htproxy.TProxyService. The AAR is generic: instead of rebuilding it per consumer package, add a small shim class in your app:

kotlin
// app/src/main/java/hev/htproxy/TProxyService.kt
package hev.htproxy

object TProxyService {
    external fun TProxyStartService(config_path: String, fd: Int): Boolean
    external fun TProxyStopService(): Boolean
    external fun TProxyIsRunning(): Boolean
    external fun TProxyGetStats(): LongArray

    init {
        System.loadLibrary("hev-socks5-tunnel")
    }
}

Then call these methods from your own code; no per-package rebuild is required. The AAR is also attached to tagged releases. Consumers that need a custom package or class name can still override PKGNAME/CLSNAME in Application.mk as shown above and build themselves.

Use Cases

Android VPN

  • SocksTun
  • Orbot

iOS

  • Tun2SocksKit

Contributors

  • arror - https://github.com/arror
  • bazuchan - https://github.com/bazuchan
  • codewithtamim - https://github.com/codewithtamim
  • dovecoteescapee - https://github.com/dovecoteescapee
  • ebrahimtahernejad - https://github.com/ebrahimtahernejad
  • heiby - https://github.com/heiby
  • hev - https://hev.cc
  • ihipop - https://ihipop.com
  • katana - https://github.com/officialkatana
  • pronebird - https://github.com/pronebird
  • saeeddev94 - https://github.com/saeeddev94
  • sskaje - https://github.com/sskaje
  • wankkoree - https://github.com/wankkoree
  • xiguagua - https://github.com/xiguagua
  • xz-dev - https://github.com/xz-dev
  • yiguous - https://github.com/yiguous
  • yujinpan - https://github.com/yujinpan
  • zheshinicheng - https://github.com/zheshinicheng

License

MIT

[^1]: See protocol specification. The hev-socks5-server supports UDP relay over TCP. [^2]: See Application.mk

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Candroiddnsfreebsdhigh-performance

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类数据库
定价开源

> 相关工具

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库