Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

shadowsocks-rust

> 安全
Open source

A Rust port of shadowsocks

10.8K stars0 likes6 views
WebsiteGitHub

About

A Rust port of shadowsocks

shadowsocks

This is a port of shadowsocks.

shadowsocks is a fast tunnel proxy that helps you bypass firewalls.

Library Description
shadowsocks shadowsocks core protocol
shadowsocks-service Services for serving shadowsocks
shadowsocks-rust Binaries running common shadowsocks services

Related Projects:

  • spyophobia/shadowsocks-gtk-rs A GUI on Linux for sslocal using GTK, discussion
  • honwen/openwrt-shadowsocks-rust OpenWRT solution for sslocal, discussion
  • cg31/shadowsocks-windows-gui-rust Windows GUI client, discussion

Build & Install

Optional Features

  • hickory-dns - Uses hickory-resolver as DNS resolver instead of tokio's builtin.

  • local-http - Allow using HTTP protocol for sslocal

    • local-http-native-tls - Support HTTPS with native-tls

    • local-http-rustls - Support HTTPS with rustls

  • local-tunnel - Allow using tunnel protocol for sslocal

  • local-socks4 - Allow using SOCKS4/4a protocol for sslocal

  • local-redir - Allow using redir (transparent proxy) protocol for sslocal

  • local-dns - Allow using dns protocol for sslocal, serves as a DNS server proxying queries to local or remote DNS servers by ACL rules

  • local-fake-dns - FakeDNS, allocating an IP address for each individual Query from a specific IP pool

  • local-tun - TUN interface support for sslocal

  • local-online-config - SIP008 Online Configuration Delivery

  • stream-cipher - Enable deprecated stream ciphers. WARN: stream ciphers are UNSAFE!

  • aead-cipher-extra - Enable non-standard AEAD ciphers

  • aead-cipher-2022 - Enable AEAD-2022 ciphers (SIP022)

  • aead-cipher-2022-extra - Enable AEAD-2022 extra ciphers (non-standard ciphers)

Memory Allocators

This project uses system (libc) memory allocator (Rust's default). But it also allows you to use other famous allocators by features:

  • jemalloc - Uses jemalloc as global memory allocator
  • mimalloc - Uses mi-malloc as global memory allocator
  • tcmalloc - Uses TCMalloc as global memory allocator. It tries to link system-wide tcmalloc by default, use vendored from source with tcmalloc-vendored.
  • snmalloc - Uses snmalloc as global memory allocator
  • rpmalloc - Uses rpmalloc as global memory allocator

crates.io

Install from crates.io:

bash
# Install from crates.io
cargo install shadowsocks-rust

then you can find sslocal and ssserver in $CARGO_HOME/bin.

Install using Homebrew

For macOS and Linux, you can install it using Homebrew:

bash
brew install shadowsocks-rust

Install using snap

…

Default configuration file path probably is /var/snap/shadowsocks-rust/common/etc/shadowsocks-rust/config.json.

Download release

Download static-linked build here.

  • Most of them are built with cross. Build environment details could be found in its README, such as glibc's version.
  • x86_64-apple-darwin, aarch64-apple-darwin are built in github's macos-latest image. Information could be found in here.
  • x86_64-pc-windows-msvc is built in github's windows-latest image. Information could be found in here.

Docker

This project provided Docker images for the linux/i386 and linux/amd64 and linux/arm64/v8 architectures.

:warning: Docker containers do not have access to IPv6 by default: Make sure to disable IPv6 Route in the client or enable IPv6 access to docker containers.

Pull from GitHub Container Registry

Docker will pull the image of the appropriate architecture from our GitHub Packages.

bash
docker pull ghcr.io/shadowsocks/sslocal-rust:latest
docker pull ghcr.io/shadowsocks/ssserver-rust:latest

Build on the local machine(Optional)

If you want to build the Docker image yourself, you need to use the BuildX.

bash
docker buildx build -t shadowsocks/ssserver-rust:latest -t shadowsocks/ssserver-rust:v1.15.2 --target ssserver .
docker buildx build -t shadowsocks/sslocal-rust:latest -t shadowsocks/sslocal-rust:v1.15.2 --target sslocal .

Run the container

You need to mount the configuration file into the container and create an external port map for the container to connect to it.

bash
docker run --name sslocal-rust \
  --restart always \
  -p 1080:1080/tcp \
  -v /path/to/config.json:/etc/shadowsocks-rust/config.json \
  -dit ghcr.io/shadowsocks/sslocal-rust:latest

docker run --name ssserver-rust \
  --restart always \
  -p 8388:8388/tcp \
  -p 8388:8388/udp \
  -v /path/to/config.json:/etc/shadowsocks-rust/config.json \
  -dit ghcr.io/shadowsocks/ssserver-rust:latest

Deploy to Kubernetes

This project provided yaml manifests for deploying to Kubernetes.

You can leverage k8s Service to expose traffic outside, like LoadBalancer or NodePort which gains more fine-grained compared with fixed host or port.

For a more interesting use case, you can use a Ingress(Istio, nginx, etc.) which routes the matched traffic to shadowsocks along with the real web service.

Using kubectl

kubectl apply -f https://github.com/shadowsocks/shadowsocks-rust/raw/master/k8s/shadowsocks-rust.yaml

You can change the config via editing the ConfigMap named shadowsocks-rust.

For more fine-grained control, use helm.

Using helm

helm install my-release k8s/chart -f my-values.yaml

Below is the common default values you can change:

…

Build from source

Use cargo to build. NOTE: RAM >= 2GiB

bash
cargo build --release

Then sslocal and ssserver will appear in ./target/(debug|release)/, it works similarly as the two binaries in the official ShadowSocks' implementation.

bash
make install TARGET=release

Then sslocal, ssserver, ssmanager and ssurl will be installed to /usr/local/bin (variable PREFIX).

For Windows users, if you have encountered any problem in building, check and discuss in #102.

target-cpu optimization

If you are building for your current CPU platform (for example, build and run on your personal computer), it is recommended to set target-cpu=native feature to let rustc generate and optimize code for the CPU running the compiler.

bash
export RUSTFLAGS="-C target-cpu=native"

Build standalone binaries

Requirements:

  • Docker
bash
./build/build-release

Then sslocal, ssserver, ssmanager, ssservice and ssurl will be packaged in

  • ./build/shadowsocks-${VERSION}-stable.x86_64-unknown-linux-musl.tar.xz
  • ./build/shadowsocks-${VERSION}-stable.x86_64-pc-windows-gnu.zip

Read Cargo.toml for more details.

For Linux with low GLIBC versions, set CROSS_CONFIG to CentOS based image:

bash
export CROSS_CONFIG=Cross-centos.toml

Getting Started

Generate a safe and secured password for a specific encryption method (aes-128-gcm in the example) with:

bash
ssservice genkey -m "aes-128-gcm"

Create a ShadowSocks' configuration file. Example

jsonc
{
    "server": "my_server_ip",
    "server_port": 8388,
    "password": "rwQc8qPXVsRpGx3uW+Y3Lj4Y42yF9Bs0xg1pmx8/+bo=",
    "method": "aes-256-gcm",
    // ONLY FOR `sslocal`
    // Delete these lines if you are running `ssserver` or `ssmanager`
    "local_address": "127.0.0.1",
    "local_port": 1080
}

Detailed explanation of the configuration file could be found in shadowsocks' documentation. (Link to original project, not maintained anymore !)

:warning: For snap installations, configuration file is most probably located in /var/snap/shadowsocks-rust/common/etc/shadowsocks-rust/config.json (see https://github.com/shadowsocks/shadowsocks-rust/issues/621 / https://github.com/shadowsocks/shadowsocks-rust/issues/1146)

In shadowsocks-rust, we also have an extended configuration file format, which is able to define more than one server. You can also disable individual servers.

…

sslocal automatically selects the best server with the lowest latency and the highest availability.

Start Shadowsocks client and server with:

bash
sslocal -c config.json
ssserver -c config.json

If you Build it with Cargo:

bash
cargo run --bin sslocal -- -c config.json
cargo run --bin ssserver -- -c config.json

List all available arguments with -h.

Usage

Start local client with configuration file

bash
# Read local client configuration from file
sslocal -c /path/to/shadowsocks.json

sslocal also supports routing its outbound TCP connection to the Shadowsocks server through a proxy or proxy chain with the outbound_proxy config key. Supported hop types are socks5://, http://, and https://, with optional user:pass@ credentials. This option is currently available through the configuration file for sslocal; ssserver supports both the config file and repeated --outbound-proxy command line flags.

jsonc
{
    "server": "server.example.com",
    "server_port": 8388,
    "password": "hello-kitty",
    "method": "aes-256-gcm",
    "local_address": "127.0.0.1",
    "local_port": 1080,
    "outbound_proxy": [
        "socks5://user:[email protected]:1080",
        "https://proxy.example.com:443",
        "http://127.0.0.1:1081"
    ]
}

Socks5 Local client

bash
# Pass all parameters via command line
sslocal -b "127.0.0.1:1080" -s "

Issues· 67 open

View all issuesOpen on GitHub
  • #2186

    systemd unit: use network-online.target instead?

    Updated Sep 28, 2026
  • #2185

    Feature request: add Unix Domain Socket listener support

    Updated Sep 28, 2026
  • #1683

    Dependency Dashboard

    Updated Sep 28, 2026
  • #2184

    AEAD-2022 TCP client can pick padding 0 for an empty first payload, which its own server rejects (~1/901 handshakes fail)

    Updated Sep 28, 2026
  • #2017

    How to expose socks5 and http proxy with username and password in sslocal?

    Updated Sep 25, 2026
  • #2175

    AEAD-2022 TCP writer reports retry buffer length after Pending, dropping appended data

    Updated Sep 13, 2026
  • #2171

    mobile client JNet VPN in app store

    Updated Sep 3, 2026
  • #2164

    在使用tun模式做透明代理流量很大的情况下,会触发panicked

    Updated Aug 10, 2026
  • #2030

    The server chosen by balancer is NOT the "best"

    Updated Aug 2, 2026
  • #2160

    Shadowsocks + xray-plugin无法安全代理udp流量?

    Updated Jul 27, 2026

> Tags

Rusthttp-proxyrustsecurityshadowsocks

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 28, 2026
Category安全
PricingOpen source

> Related tools

O
OWASP ZAP
开源 Web 应用安全扫描器
O
owasp-wstg-tracker
Simple web app to track OWASP WSTG security testing progress
H
homebridge-mi-gateway-security
XiaoMi Gateway Security plugin for HomeBridge.