これはShadowsocksのポートです。
shadowsocks は、ファイアウォールのバイパスに役立つ高速トンネル プロキシです。
| 図書館 | 説明 |
|---|---|
| シャドウソックス | シャドウソックスコアプロトコル |
| シャドウソックスサービス | Shadowsock を提供するサービス |
| シャドウソックス-錆び | 一般的な Shadowsock サービスを実行するバイナリ |
関連プロジェクト:
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 - FakeDNS、特定の IP プールから個々のクエリごとに IP アドレスを割り当てます。
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 sslocalとssserver $CARGO_HOME/binにあります。
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 (ストレッチ)、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 などのトラフィックを外部に公開すると、固定ホストやポートと比較してより詳細な粒度が得られます。
より興味深い使用例として、一致したトラフィックを実際の Web サービスとともにシャドウソックスにルーティングする 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 実装の 2 つのバイナリと同様に機能します。
make install TARGET=release次に、 sslocal 、 ssserver 、 ssmanagerおよびssurlが/usr/local/bin (変数 PREFIX) にインストールされます。
Windows ユーザーの場合、ビルド中に問題が発生した場合は、#102 を確認して相談してください。
現在の CPU プラットフォーム向けにビルドしている場合 (たとえば、パーソナル コンピュータでビルドして実行する場合)、コンパイラを実行している CPU 向けにrustcコードを生成および最適化できるように、 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を使用)、OS X 10.10+、FreeBSD など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 ,