이것은 Shadowsocks의 항구입니다.
Shadowsocks는 방화벽을 우회하는 데 도움이 되는 빠른 터널 프록시입니다.
| 도서관 | 설명 |
|---|---|
| 그림자 양말 | Shadowsocks 핵심 프로토콜 |
| 섀도우삭스 서비스 | Shadowsock 제공 서비스 |
| 그림자 양말 - 녹 | 일반적인 Shadowsocks 서비스를 실행하는 바이너리 |
관련 프로젝트:
sslocal 용 Linux GUI, 토론sslocal 용 OpenWRT 솔루션, 토론 hickory-dns - tokio 의 내장 기능 대신 hickory-resolver DNS 해석기로 사용합니다.
local-http - sslocal 에 HTTP 프로토콜 사용을 허용합니다.
local-http-native-tls - native-tls 로 HTTPS 지원
local-http-rustls - rustls 로 HTTPS 지원
local-tunnel - sslocal 에 대한 터널 프로토콜 사용을 허용합니다.
local-socks4 - sslocal 에 SOCKS4/4a 프로토콜 사용을 허용합니다.
local-redir - sslocal 에 redir(투명 프록시) 프로토콜 사용을 허용합니다.
local-dns - sslocal 에 대한 DNS 프로토콜 사용을 허용하고 ACL 규칙에 따라 로컬 또는 원격 DNS 서버에 대한 쿼리를 프록시하는 DNS 서버 역할을 합니다.
local-fake-dns - 특정 IP 풀에서 각 개별 쿼리에 대한 IP 주소를 할당하는 FakeDNS
local-tun - sslocal 에 대한 TUN 인터페이스 지원
local-online-config - SIP008 온라인 구성 전달
stream-cipher - 더 이상 사용되지 않는 스트림 암호를 활성화합니다. 경고: 스트림 암호는 안전하지 않습니다!
aead-cipher-extra - 비표준 AEAD 암호 활성화
aead-cipher-2022 - AEAD-2022 암호 활성화(SIP022)
aead-cipher-2022-extra - AEAD-2022 추가 암호 활성화(비표준 암호)
이 프로젝트는 시스템(libc) 메모리 할당자(Rust의 기본값)를 사용합니다. 그러나 기능별로 다른 유명한 할당자를 사용할 수도 있습니다.
jemalloc - 전역 메모리 할당자로 jemalloc을 사용합니다.mimalloc - mi-malloc을 전역 메모리 할당자로 사용합니다.tcmalloc - TCMalloc을 전역 메모리 할당자로 사용합니다. 기본적으로 시스템 전체의 tcmalloc 연결을 시도하고, tcmalloc-vendored 와 함께 소스에서 Vendored를 사용합니다.snmalloc - snmalloc을 전역 메모리 할당자로 사용합니다.rpmalloc - rpmalloc을 전역 메모리 할당자로 사용합니다.crates.io에서 설치:
# Install from crates.io
cargo install shadowsocks-rust $CARGO_HOME/bin 에서 sslocal 및 ssserver 찾을 수 있습니다.
macOS 및 Linux의 경우 Homebrew를 사용하여 설치할 수 있습니다.
brew install shadowsocks-rust # Install from snapstore
snap install shadowsocks-rust
# List services
snap services shadowsocks-rust
# Enable and start shadowsocks-rust.sslocal-daemon snap service
snap start --enable shadowsocks-rust.sslocal-daemon
# Show generated systemd service status
systemctl status snap.shadowsocks-rust.sslocal-daemon.service
# Override generated systemd service (configure startup options)
systemctl edit snap.shadowsocks-rust.sslocal-daemon.service
# # NOTE: you can pass args to sslocal:
# # [Service]
# # ExecStart=
# # ExecStart=/usr/bin/snap run shadowsocks-rust.sslocal-daemon -b "127.0.0.1:1080" --server-url "ss://...."
# Restart generated systemd service to apply changes
systemctl restart snap.shadowsocks-rust.sslocal-daemon.service
# ... and show service status
systemctl status snap.shadowsocks-rust.sslocal-daemon.service여기에서 정적 링크 빌드를 다운로드하세요.
build-windows : x86_64-pc-windows-msvc 용 빌드build-linux : x86_64-unknown-linux-gnu , Debian 9(Stretch), GLIBC 2.18용 빌드build-docker : x86_64-unknown-linux-musl , x86_64-pc-windows-gnu , ...용 빌드(정적으로 링크됨) 이 프로젝트는 linux/i386 , linux/amd64 및 linux/arm64/v8 아키텍처용 Docker 이미지를 제공했습니다.
⚠️ Docker 컨테이너는 기본적으로 IPv6에 액세스할 수 없습니다 . 클라이언트에서 IPv6 경로를 비활성화하거나 Docker 컨테이너에 대한 IPv6 액세스를 활성화해야 합니다.
Docker는 GitHub 패키지에서 적절한 아키텍처의 이미지를 가져옵니다.
docker pull ghcr.io/shadowsocks/sslocal-rust:latest
docker pull ghcr.io/shadowsocks/ssserver-rust:latestDocker 이미지를 직접 빌드하려면 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 . 구성 파일을 컨테이너에 탑재하고 컨테이너가 연결할 외부 포트 맵을 생성해야 합니다.
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이 프로젝트는 Kubernetes에 배포하기 위한 yaml 매니페스트를 제공했습니다.
k8s 서비스를 활용하여 고정 호스트나 포트에 비해 더 세분화된 LoadBalancer 또는 NodePort와 같은 외부 트래픽을 노출할 수 있습니다.
보다 흥미로운 사용 사례를 위해 일치하는 트래픽을 실제 웹 서비스와 함께 Shadowsock으로 라우팅하는 Ingress(Istio, nginx 등)를 사용할 수 있습니다.
kubectl 사용 kubectl apply -f https://github.com/shadowsocks/shadowsocks-rust/raw/master/k8s/shadowsocks-rust.yaml
shadowsocks-rust 라는 ConfigMap을 편집하여 구성을 변경할 수 있습니다.
보다 세밀하게 제어하려면 helm 사용하세요.
helm 사용 helm install my-release k8s/chart -f my-values.yaml
변경할 수 있는 일반적인 기본값은 다음과 같습니다.
# This is the shadowsocks config which will be mount to /etc/shadowocks-rust.
# You can put arbitrary yaml here, and it will be translated to json before mounting.
servers :
- server : " :: "
server_port : 8388
service_port : 80 # the k8s service port, default to server_port
password : mypassword
method : aes-256-gcm
fast_open : true
mode : tcp_and_udp
# plugin: v2ray-plugin
# plugin_opts: server;tls;host=github.com
# Whether to download v2ray and xray plugin.
downloadPlugins : false
# Name of the ConfigMap with config.json configuration for shadowsocks-rust.
configMapName : " "
service :
# Change to LoadBalancer if you are behind a cloud provider like aws, gce, or tke.
type : ClusterIP
# Bind shadowsocks port port to host, i.e., we can use host:port to access shawdowsocks server.
hostPort : false
replicaCount : 1
image :
repository : ghcr.io/shadowsocks/ssserver-rust
pullPolicy : IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag : " latest "화물을 사용하여 건설하세요. 참고: RAM >= 2GiB
cargo build --release 그러면 sslocal 및 ssserver ./target/(debug|release)/ 에 나타나며 공식 ShadowSocks 구현의 두 바이너리와 유사하게 작동합니다.
make install TARGET=release 그런 다음 sslocal , ssserver , ssmanager 및 ssurl /usr/local/bin (변수 PREFIX)에 설치됩니다.
Windows 사용자의 경우, 구축 시 문제가 발생하는 경우 #102를 확인하고 논의하시기 바랍니다.
현재 CPU 플랫폼용으로 빌드하는 경우(예: 개인용 컴퓨터에서 빌드 및 실행), rustc 가 컴파일러를 실행하는 CPU용 코드를 생성하고 최적화할 수 있도록 target-cpu=native 기능을 설정하는 것이 좋습니다.
export RUSTFLAGS= " -C target-cpu=native "요구사항:
./build/build-release 그런 다음 sslocal , ssserver , ssmanager 및 ssurl 이 패키지됩니다.
./build/shadowsocks-${VERSION}-stable.x86_64-unknown-linux-musl.tar.xz./build/shadowsocks-${VERSION}-stable.x86_64-pc-windows-gnu.zip 자세한 내용은 Cargo.toml 읽어보세요.
다음을 사용하여 특정 암호화 방법(예: aes-128-gcm )에 대해 안전하고 보안이 유지되는 비밀번호를 생성합니다.
ssservice genkey -m " aes-128-gcm "ShadowSocks의 구성 파일을 만듭니다. 예
{
"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
}구성 파일에 대한 자세한 설명은 Shadowsocks 문서에서 찾을 수 있습니다. (원래 프로젝트에 대한 링크, 더 이상 유지되지 않음!)
⚠️ 스냅 설치의 경우 구성 파일은/var/snap/shadowsocks-rust/common/etc/shadowsocks-rust/config.json에 있을 가능성이 높습니다(#621 / #1146 참조).
Shadowsocks-rust에는 둘 이상의 서버를 정의할 수 있는 확장 구성 파일 형식도 있습니다. 개별 서버를 비활성화할 수도 있습니다.
{
"servers" : [
{
"server" : "127.0.0.1" ,
"server_port" : 8388 ,
"password" : "rwQc8qPXVsRpGx3uW+Y3Lj4Y42yF9Bs0xg1pmx8/+bo=" ,
"method" : "aes-256-gcm" ,
"timeout" : 7200
} ,
{
"server" : "127.0.0.1" ,
"server_port" : 8389 ,
"password" : "/dliNXn5V4jg6vBW4MnC1I8Jljg9x7vSihmk6UZpRBM=" ,
"method" : "chacha20-ietf-poly1305"
} ,
{
"disabled" : true ,
"server" : "eg.disable.me" ,
"server_port" : 8390 ,
"password" : "mGvbWWay8ueP9IHnV5F1uWGN2BRToiVCAWJmWOTLU24=" ,
"method" : "chacha20-ietf-poly1305"
}
] ,
// ONLY FOR `sslocal`
// Delete these lines if you are running `ssserver` or `ssmanager`
"local_port" : 1080 ,
"local_address" : "127.0.0.1"
} sslocal 대기 시간이 가장 짧고 가용성이 가장 높은 최상의 서버를 자동으로 선택합니다.
다음을 사용하여 Shadowsocks 클라이언트 및 서버를 시작합니다.
sslocal -c config.json
ssserver -c config.jsonCargo로 빌드하는 경우:
cargo run --bin sslocal -- -c config.json
cargo run --bin ssserver -- -c config.json -h 사용하여 사용 가능한 모든 인수를 나열합니다.
구성 파일을 사용하여 로컬 클라이언트 시작
# Read local client configuration from file
sslocal -c /path/to/shadowsocks.json # Pass all parameters via command line
sslocal -b " 127.0.0.1:1080 " -s " [::1]:8388 " -m " aes-256-gcm " -k " hello-kitty " --plugin " v2ray-plugin " --plugin-opts " server;tls;host=github.com "
# Pass server with SIP002 URL
sslocal -b " 127.0.0.1:1080 " --server-url " ss://[email protected]:8388/?plugin=v2ray-plugin%3Bserver%3Btls%3Bhost%3Dgithub.com "sslocal -b " 127.0.0.1:3128 " --protocol http -s " [::1]:8388 " -m " aes-256-gcm " -k " hello-kitty " --protocol http 제외하고 모든 매개변수는 Socks5 클라이언트와 동일합니다.
# Set 127.0.0.1:8080 as the target for forwarding to
sslocal --protocol tunnel -b " 127.0.0.1:3128 " -f " 127.0.0.1:8080 " -s " [::1]:8388 " -m " aes-256-gcm " -k " hello-kitty "--protocol tunnel 로컬 클라이언트 터널 모드를 활성화합니다.-f "127.0.0.1:8080 터널 대상 주소를 설정합니다.참고 : 현재는
iptables 대상 REDIRECT 및 TPROXY 사용)pf 포함) sslocal -b " 127.0.0.1:60080 " --protocol redir -s " [::1]:8388 " -m " aes-256-gcm " -k " hello-kitty " --tcp-redir " redirect " --udp-redir " tproxy " iptables 구성과의 연결을 sslocal 수신 대기 중인 포트로 리디렉션합니다.
--protocol redir 로컬 클라이언트 Redir 모드를 활성화합니다.--tcp-redir TCP 모드를 REDIRECT (Linux)로 설정합니다.--udp-redir UDP 모드를 TPROXY (Linux)로 설정합니다.참고 : 현재는
이름이 tun0 인 Tun 인터페이스를 만듭니다.
ip tuntap add mode tun tun0
ifconfig tun0 inet 10.255.0.1 netmask 255.255.255.0 up --protocol tun 사용하여 sslocal 시작하고 tun0 에 바인딩합니다.
sslocal --protocol tun -s " [::1]:8388 " -m " aes-256-gcm " -k " hello-kitty " --outbound-bind-interface lo0 --tun-interface-name tun0sslocal --protocol tun -s " [::1]:8388 " -m " aes-256-gcm " -k " hello-kitty " --outbound-bind-interface lo0 --tun-interface-address 10.255.0.1/24 주소가 10.255.0.1 이고 넷마스크가 255.255.255.0 인 Tun 인터페이스가 생성됩니다.
Wintun에서 wintun.dll 다운로드하고 Shadowsocks의 실행 가능한 바이너리가 있는 폴더나 시스템 PATH에 넣습니다.
sslocal -- protocol tun - s " [::1]:8388 " - m " aes-256-gcm " - k " hello-kitty " -- outbound - bind - interface " Ethernet 0 " -- tun - interface - name " shadowsocks " --features "winservice" 활성화하여 컴파일합니다(기본 빌드에는 포함되지 않음).
cargo build --release --bin " sswinservice " --features " winservice "Windows 서비스(PowerShell)로 설치합니다.
New-Service - Name " shadowsocks-local-service " `
- DisplayName " Shadowsocks Local Service " `
- BinaryPathName " <Pathto>sswinservice.exe local -c <Pathto>local_config.json " sswinservice Windows 서비스로 설치하는 다른 방법(예: sc 명령)이 있습니다.
-BinaryPathName 에는 sswinservice.exe 뿐만 아니라 local -c local_config.json 도 포함되어 있음을 알 수 있습니다. 이러한 명령줄 매개변수는 Windows 서비스가 시작될 때 기본 매개변수로 사용됩니다. 사용자 정의된 매개변수를 사용하여 서비스를 시작할 수도 있습니다.
Microsoft 문서에서 자세히 알아보세요.
sswinservice 의 매개변수는 ssservice 와 정확히 동일하게 작동합니다. local , server 및 manager 하위 명령을 지원합니다.
# Read server configuration from file
ssserver -c /path/to/shadowsocks.json
# Pass all parameters via command line
ssserver -s " [::]:8388 " -m " aes-256-gcm " -k " hello-kitty " --plugin " v2ray-plugin " --plugin-opts " server;tls;host=github.com "지원되는 다중 사용자 관리 API:
add - 서버 인스턴스를 시작합니다.remove - 기존 서버 인스턴스를 삭제합니다.list - 현재 실행 중인 모든 서버를 나열합니다.ping - 모든 서버의 통계 데이터를 나열합니다. 참고: stat 명령은 지원되지 않습니다. 서버는 관리자 자체와 동일한 프로세스에서 실행되기 때문입니다.
# Start it just with --manager-address command line parameter
ssmanager --manager-address " 127.0.0.1:6100 "
# For *nix system, manager can bind to unix socket address
ssmanager --manager-address " /tmp/shadowsocks-manager.sock "
# You can also provide a configuration file
#
# `manager_address` key must be provided in the configuration file
ssmanager -c /path/to/shadowsocks.json
# Create one server by UDP
echo ' add: {"server_port":8388,"password":"hello-kitty"} ' | nc -u ' 127.0.0.1 ' ' 6100 '
# Close one server by unix socket
echo ' remove: {"server_port":8388} ' | nc -Uu ' /tmp/shadowsocks-manager.sock '관리자 UI에 대한 자세한 내용은 Shadowsocks-manager 프로젝트에서 확인하세요.
예시 구성:
{
// Required option
// Address that ssmanager is listening on
"manager_address" : "127.0.0.1" ,
"manager_port" : 6100 ,
// Or bind to a Unix Domain Socket
"manager_address" : "/tmp/shadowsocks-manager.sock" ,
"servers" : [
// These servers will be started automatically when ssmanager is started
] ,
// Outbound socket binds to this IP address
// For choosing different network interface on the same machine
"local_address" : "xxx.xxx.xxx.xxx" ,
// Other options that may be passed directly to new servers
} {
// LOCAL: Listen address. This is exactly the same as `locals[0]`
// SERVER: Bind address for remote sockets, mostly used for choosing interface
// Don't set it if you don't know what's this for.
"local_address" : "127.0.0.1" ,
"local_port" : 1080 ,
// Extended multiple local configuration
"locals" : [
{
// Basic configuration, a SOCKS5 local server
"local_address" : "127.0.0.1" ,
"local_port" : 1080 ,
// OPTIONAL. Setting the `mode` for this specific local server instance.
// If not set, it will derive from the outer `mode`
"mode" : "tcp_and_udp" ,
// OPTIONAL. Authentication configuration file
// Configuration file document could be found in the next section.
"socks5_auth_config_path" : "/path/to/auth.json" ,
// OPTIONAL. Instance specific ACL
"acl" : "/path/to/acl/file.acl" ,
// OPTIONAL. macOS launchd activate socket
"launchd_tcp_socket_name" : "TCPListener" ,
"launchd_udp_socket_name" : "UDPListener"
} ,
{
// SOCKS5, SOCKS4/4a local server
"protocol" : "socks" ,
// Listen address
"local_address" : "127.0.0.1" ,
"local_port" : 1081 ,
// OPTIONAL. Enables UDP relay
"mode" : "tcp_and_udp" ,
// OPTIONAL. Customizing the UDP's binding address. Depending on `mode`, if
// - TCP is enabled, then SOCKS5's UDP Association command will return this address
// - UDP is enabled, then SOCKS5's UDP server will listen to this address.
"local_udp_address" : "127.0.0.1" ,
"local_udp_port" : 2081 ,
// OPTIONAL. macOS launchd activate socket
"launchd_tcp_socket_name" : "TCPListener" ,
"launchd_udp_socket_name" : "UDPListener"
} ,
{
// Tunnel local server (feature = "local-tunnel")
"protocol" : "tunnel" ,
// Listen address
"local_address" : "127.0.0.1" ,
"local_port" : 5353 ,