A Rust port of 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:
sslocal using GTK, discussionsslocal, discussionhickory-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)
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 allocatormimalloc - Uses mi-malloc as global memory allocatortcmalloc - 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 allocatorrpmalloc - Uses rpmalloc as global memory allocatorInstall from crates.io:
# Install from crates.io
cargo install shadowsocks-rustthen you can find sslocal and ssserver in $CARGO_HOME/bin.
For macOS and Linux, you can install it using Homebrew:
brew install shadowsocks-rust…Default configuration file path probably is /var/snap/shadowsocks-rust/common/etc/shadowsocks-rust/config.json.
Download static-linked build here.
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.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.
Docker will pull the image of the appropriate architecture from our GitHub Packages.
docker pull ghcr.io/shadowsocks/sslocal-rust:latest
docker pull ghcr.io/shadowsocks/ssserver-rust:latestIf you want to build the Docker image yourself, you need to use the BuildX.
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 .You need to mount the configuration file into the container and create an external port map for the container to connect to it.
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:latestThis 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.
kubectlkubectl 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.
helmhelm install my-release k8s/chart -f my-values.yaml
Below is the common default values you can change:
…Use cargo to build. NOTE: RAM >= 2GiB
cargo build --releaseThen sslocal and ssserver will appear in ./target/(debug|release)/, it works similarly as the two binaries in the official ShadowSocks' implementation.
make install TARGET=releaseThen 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.
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.
export RUSTFLAGS="-C target-cpu=native"Requirements:
./build/build-releaseThen 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.zipRead Cargo.toml for more details.
For Linux with low GLIBC versions, set CROSS_CONFIG to CentOS based image:
export CROSS_CONFIG=Cross-centos.tomlGenerate a safe and secured password for a specific encryption method (aes-128-gcm in the example) with:
ssservice genkey -m "aes-128-gcm"Create a ShadowSocks' configuration file. Example
{
"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:
sslocal -c config.json
ssserver -c config.jsonIf you Build it with Cargo:
cargo run --bin sslocal -- -c config.json
cargo run --bin ssserver -- -c config.jsonList all available arguments with -h.
Start local client with configuration file
# Read local client configuration from file
sslocal -c /path/to/shadowsocks.jsonsslocal 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.
{
"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"
]
}# Pass all parameters via command line
sslocal -b "127.0.0.1:1080" -s "systemd unit: use network-online.target instead?
Feature request: add Unix Domain Socket listener support
Dependency Dashboard
AEAD-2022 TCP client can pick padding 0 for an empty first payload, which its own server rejects (~1/901 handshakes fail)
How to expose socks5 and http proxy with username and password in sslocal?
AEAD-2022 TCP writer reports retry buffer length after Pending, dropping appended data
mobile client JNet VPN in app store
在使用tun模式做透明代理流量很大的情况下,会触发panicked
The server chosen by balancer is NOT the "best"
Shadowsocks + xray-plugin无法安全代理udp流量?