hev socks5 tunnel
2.7.5

UNIX에 대한 SOOKS5 프록시 (Tun2Socks)의 터널.
자세한 내용은 여기를 참조하십시오.






git clone --recursive https://github.com/heiher/hev-socks5-tunnel
cd hev-socks5-tunnel
makemkdir hev-socks5-tunnel
cd hev-socks5-tunnel
git clone --recursive https://github.com/heiher/hev-socks5-tunnel jni
ndk-buildgit clone --recursive https://github.com/heiher/hev-socks5-tunnel
cd hev-socks5-tunnel
# will generate HevSocks5Tunnel.xcframework
./build-apple.shgit clone --recursive https://github.com/heiher/hev-socks5-tunnel
cd hev-socks5-tunnel
# Static library
make static
# Shared library
make shared tunnel :
# Interface name
name : tun0
# Interface MTU
mtu : 8500
# Multi-queue
multi-queue : false
# IPv4 address
ipv4 : 198.18.0.1
# IPv6 address
ipv6 : ' fc00::1 '
# Post up script
# post-up-script: up.sh
# Pre down script
# pre-down-script: down.sh
socks5 :
# Socks5 server port
port : 1080
# Socks5 server address (ipv4/ipv6)
address : 127.0.0.1
# Socks5 UDP relay mode (tcp|udp)
udp : ' udp '
# Socks5 handshake using pipeline mode
# pipeline: false
# Socks5 server username
# username: 'username'
# Socks5 server password
# password: 'password'
# Socket mark
# mark: 0
# misc:
# task stack size (bytes)
# task-stack-size: 86016
# tcp buffer size (bytes)
# tcp-buffer-size: 65536
# connect timeout (ms)
# connect-timeout: 5000
# read-write timeout (ms)
# read-write-timeout: 60000
# stdout, stderr or file-path
# log-file: stderr
# debug, info, warn or error
# log-level: warn
# If present, run as a daemon with this pid file
# pid-file: /run/hev-socks5-tunnel.pid
# If present, set rlimit nofile; else use default value
# limit-nofile: 65535 # Set socks5.mark = 438
bin/hev-socks5-tunnel conf/main.yml
# 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 # 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 utun99
sudo route change -inet6 default -interface utun99iOS와 같은 저 메모리 시스템에서는 TCP 버퍼 및 작업 스택의 크기를 줄이면 메모리 외 문제를 방지 할 수 있습니다.
misc :
# task stack size (bytes)
task-stack-size : 24576 # 20480 + tcp-buffer-size
# tcp buffer size (bytes)
tcp-buffer-size : 4096 version : " 3.9 "
services :
client :
image : alpine:latest # just for network testing
tty : true # you can test network in terminal
depends_on :
tun :
condition : service_healthy
network_mode : " service:tun "
tun :
image : ghcr.io/heiher/hev-socks5-tunnel:latest # `latest` for the latest published version; `nightly` for the latest source build; `vX.Y.Z` for the specific version
cap_add :
- NET_ADMIN # needed
devices :
- /dev/net/tun:/dev/net/tun # needed
environment :
TUN : tun0 # optional, tun interface name, default `tun0`
MTU : 8500 # optional, MTU is MTU, default `8500`
IPV4 : 198.18.0.1 # optional, tun interface ip, default `198.18.0.1`
TABLE : 20 # optional, ip route table id, default `20`
MARK : 438 # optional, ip route rule mark, dec or hex format, default `438`
SOCKS5_ADDR : a.b.c.d # socks5 proxy server address
SOCKS5_PORT : 1080 # socks5 proxy server port
SOCKS5_USERNAME : user # optional, socks5 proxy username, only set when need to auth
SOCKS5_PASSWORD : pass # optional, socks5 proxy password, only set when need to auth
SOCKS5_UDP_MODE : udp # optional, UDP relay mode, default `udp`, other option `tcp`
IPV4_INCLUDED_ROUTES : 0.0.0.0/0 # optional, demo means proxy all traffic. for multiple network segments, join with `,` or `n`
IPV4_EXCLUDED_ROUTES : a.b.c.d # optional, demo means exclude traffic from the proxy itself. for multiple network segments, join with `,` or `n`
LOG_LEVEL : warn # optional, default `warn`, other option `debug`/`info`/`error`
dns :
- 8.8.8.8다음과 같은 여러 네트워크 세그먼트로 경로 규칙을 설정할 수도 있습니다.
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 /**
* hev_socks5_tunnel_main:
* @config_path: config file path
* @tun_fd: tunnel file descriptor
*
* Start and run the socks5 tunnel, this function will blocks until the
* hev_socks5_tunnel_quit is called or an error occurs.
*
* Alias of hev_socks5_tunnel_main_from_file
*
* Returns: returns zero on successful, otherwise returns -1.
*
* Since: 2.4.6
*/
int hev_socks5_tunnel_main ( const char * config_path , int tun_fd );
/**
* hev_socks5_tunnel_main_from_file:
* @config_path: config file path
* @tun_fd: tunnel file descriptor
*
* Start and run the socks5 tunnel, this function will blocks until the
* hev_socks5_tunnel_quit is called or an error occurs.
*
* Returns: returns zero on successful, otherwise returns -1.
*
* Since: 2.6.7
*/
int hev_socks5_tunnel_main_from_file ( const char * config_path , int tun_fd );
/**
* hev_socks5_tunnel_main_from_str:
* @config_str: string config
* @config_len: the byte length of string config
* @tun_fd: tunnel file descriptor
*
* Start and run the socks5 tunnel, this function will blocks until the
* hev_socks5_tunnel_quit is called or an error occurs.
*
* Returns: returns zero on successful, otherwise returns -1.
*
* Since: 2.6.7
*/
int hev_socks5_tunnel_main_from_str ( const unsigned char * config_str ,
unsigned int config_len , int tun_fd );
/**
* hev_socks5_tunnel_quit:
*
* Stop the socks5 tunnel.
*
* Since: 2.4.6
*/
void hev_socks5_tunnel_quit ( void );
/**
* hev_socks5_tunnel_stats:
* @tx_packets (out): transmitted packets
* @tx_bytes (out): transmitted bytes
* @rx_packets (out): received packets
* @rx_bytes (out): received bytes
*
* Retrieve tunnel interface traffic statistics.
*
* Since: 2.6.5
*/
void hev_socks5_tunnel_stats ( size_t * tx_packets , size_t * tx_bytes ,
size_t * rx_packets , size_t * rx_bytes );MIT