首先在linux vps上搭建rust环境:
/usr/local/lib/rustlib/uninstall.sh 先卸载旧版的rust。
curl https://sh.rustup.rs -sSf | sh # -s -- --channel=nightly
curl https://sh.rustup.rs -sSf | sh # -s -- --channel=nightly
(必须是nightly版。)
会显示:
Welcome to Rust!
This will download and install the official compiler for the Rust programming
language, and its package manager, Cargo.
It will add the cargo, rustc, rustup and other commands to Cargo's bin
directory, located at:
/root/.cargo/bin
This path will then be added to your PATH environment variable by modifying the
profile file located at:
/root/.profile
You can uninstall at any time with rustup self uninstall and these changes will
be reverted.
Current installation options:
default host triple: x86_64-unknown-linux-gnu
default toolchain: stable
modify PATH variable: yes
1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
然后运行:
source $HOME/.cargo/env
This will download and install the official compiler for the Rust programming
language, and its package manager, Cargo.
It will add the cargo, rustc, rustup and other commands to Cargo's bin
directory, located at:
/root/.cargo/bin
This path will then be added to your PATH environment variable by modifying the
profile file located at:
/root/.profile
You can uninstall at any time with rustup self uninstall and these changes will
be reverted.
Current installation options:
default host triple: x86_64-unknown-linux-gnu
default toolchain: stable
modify PATH variable: yes
1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
然后运行:
source $HOME/.cargo/env
然后,
git clone https://github.com/zonyitoo/shadowsocks-rust
cd shadowsocks-rust
root@AR:~/shadowsocks-rust# ls
appveyor.yml Cargo.toml LICENSE src
Cargo.lock examples README.md
root@AR:~/shadowsocks-rust#
SODIUM_BUILD_STATIC=yes
cargo build --release(要求linux vps的内存至少为1 gb,否则运行的过程会遇错。即:内存不够,无法完成build。如果linux vps的内存为1 gb,还是build失败,请重启vps,这是为了释放内存,然后再运行cargo build --release
另外需先编译libsodium,否则build会遇错:
wget https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz
tar zxvf libsodium-1.0.18.tar.gz
cd libsodium-1.0.18
./configure
make
make install
ldconfig
https://github.com/shadowsocks/shadowsocks-rust/issues/155 )
会显示:
...
Compiling shadowsocks-rust v1.6.11 (file:///root/shadowsocks-rust)
Finished release [optimized] target(s) in 217.2 secs
root@AR:~/shadowsocks-rust# ls
appveyor.yml Cargo.toml LICENSE src
Cargo.lock examples README.md target
(生成了target目录)
root@AR:~/shadowsocks-rust# cd target
root@AR:~/shadowsocks-rust/target# ls
release
root@AR:~/shadowsocks-rust/target# cd release
root@AR:~/shadowsocks-rust/target/release# ls
build examples native sslocal ssurl
deps libshadowsocks.rlib socks5-tool ssserver
root@AR:~/shadowsocks-rust/target/release# nano config.json
root@AR:~/shadowsocks-rust/target/release# cat config.json
{
"server": "0.0.0.0",
"server_port": 8188,
"local_address": "127.0.0.1",
"local_port": 1080,
"password": "mypassword",
"timeout": 600,
"method": "aes-256-gcm"
}
(这里的 "local_address": "127.0.0.1",可以不写出来。但是在客户机器上,则一定要写出来。注意:加密方法不再支持aes-256-cfb, 但支持aes-256-gcm)
root@AR:~/shadowsocks-rust/target/release# ./ssserver -c config.json
不过,这条命令./ssserver -c config.json 是运行在前台的,容易退出。我们可利用systemd
来让该命令运行为service:
nano /etc/systemd/system/shadowsocks-rust.service
其内容为:
[Unit]
After=network.target
[Service]
ExecStart=/root/shadowsocks-rust/target/release/ssserver -c /root/shadowsocks-rust/target/release/config.json
Restart=always
[Install]
WantedBy=multi-user.target
然后运行:
systemctl start shadowsocks-rust
systemctl enable shadowsocks-rust
这样,服务器端就搭建好了。
在客户机器上。
如果你的是windows机器,那么在shadowsocks的windows客户端里,填入相关参数即可。
如果你的是mac,那么在shadowsocks的mac客户端-shadowsocksX里,填入相关参数即可.当然你也可在mac的终端里安装rust和运行有关的命令来启动shadowsocks-rust。操作如下:
brew install curl
curl -sSf https://static.rust-lang.org/rustup.sh | sh -s -- --channel=nightly
运行命令后,显示:
...
install: creating uninstall script at /usr/local/lib/rustlib/uninstall.sh
install: installing component 'rustc'
install: installing component 'rust-docs'
install: installing component 'cargo'
Rust is ready to roll.
则表明安装成功。
然后,
git clone https://github.com/zonyitoo/shadowsocks-rust
cd shadowsocks-rust
cargo build --release
会显示:
...
Compiling coio v0.2.0 (https://github.com/zonyitoo/coio-rs.git#d1714e13)
Compiling shadowsocks-rust v0.9.14 (file:///root/shadowsocks-rust)
src/crypto/table.rs:28:5: 28:27 warning: unused import, #[warn(unused_imports)] on by default
src/crypto/table.rs:28 use crypto::digest::Digest;
这表明shadowsocks-rust编译成功。
yudeMacBook-Air:shadowsocks-rust brite$ ls
Cargo.lock LICENSE appveyor.yml src
Cargo.toml README.md examples target
yudeMacBook-Air:shadowsocks-rust brite$ cd target
yudeMacBook-Air:target brite$ ls
release
yudeMacBook-Air:target brite$ cd release
yudeMacBook-Air:release brite$ ls
build libshadowsocks.rlib ssserver
config.json native ssurl
deps socks5-tool
examples sslocal
yudeMacBook-Air:release brite$ nano config.json
(config.json的内容如下:
{
"server": "my_server_ip",
"server_port": 8188,
"local_address": "127.0.0.1",
"local_port": 1080,
"password": "mypassword",
"timeout": 600,
"method": "aes-256-gcm"
} )
yudeMacBook-Air:release brite$ nohup ./sslocal -c config.json > /dev/null &
这样shadowsocks-rust的客户端就搭建好了。注意:加密方法不再支持aes-256-cfb, 但支持aes-256-gcm。
然后设置浏览器的socks5代理为127.0.0.1:1080,即可翻墙。
项目地址:https://github.com/zonyitoo/shadowsocks-rust
(https://github.com/loggerhead/shadowsocks-rust,
https://github.com/loggerhead/shadowsocks-rust/issues/7)
-------------
如果你的linux vps的内存太少,编译shadowsocks-rust可能会失败,那么就直接下载它的可执行文件,拿来用即可:
wget https://github.com/shadowsocks/shadowsocks-rust/releases/download/v1.6.10/shadowsocks-v1.6.10-release.x86_64-unknown-linux-musl.tar.xz
tar Jxvf shadowsocks-v1.6.10-release.x86_64-unknown-linux-musl.tar.xz
显示:
sslocal
ssserver
ssurl
root@RegalMusty-VM:~# ./ssserver -c config.json
https://github.com/shadowsocks/shadowsocks-rust/releases
------
https://github.com/ZiJiaW/shadowsocks-rs-simplified
brew install curl
curl -sSf https://static.rust-lang.org/rustup.sh | sh -s -- --channel=nightly
运行命令后,显示:
...
install: creating uninstall script at /usr/local/lib/rustlib/uninstall.sh
install: installing component 'rustc'
install: installing component 'rust-docs'
install: installing component 'cargo'
Rust is ready to roll.
则表明安装成功。
然后,
git clone https://github.com/zonyitoo/shadowsocks-rust
cd shadowsocks-rust
cargo build --release
会显示:
...
Compiling coio v0.2.0 (https://github.com/zonyitoo/coio-rs.git#d1714e13)
Compiling shadowsocks-rust v0.9.14 (file:///root/shadowsocks-rust)
src/crypto/table.rs:28:5: 28:27 warning: unused import, #[warn(unused_imports)] on by default
src/crypto/table.rs:28 use crypto::digest::Digest;
这表明shadowsocks-rust编译成功。
yudeMacBook-Air:shadowsocks-rust brite$ ls
Cargo.lock LICENSE appveyor.yml src
Cargo.toml README.md examples target
yudeMacBook-Air:shadowsocks-rust brite$ cd target
yudeMacBook-Air:target brite$ ls
release
yudeMacBook-Air:target brite$ cd release
yudeMacBook-Air:release brite$ ls
build libshadowsocks.rlib ssserver
config.json native ssurl
deps socks5-tool
examples sslocal
yudeMacBook-Air:release brite$ nano config.json
(config.json的内容如下:
{
"server": "my_server_ip",
"server_port": 8188,
"local_address": "127.0.0.1",
"local_port": 1080,
"password": "mypassword",
"timeout": 600,
"method": "aes-256-gcm"
} )
yudeMacBook-Air:release brite$ nohup ./sslocal -c config.json > /dev/null &
这样shadowsocks-rust的客户端就搭建好了。注意:加密方法不再支持aes-256-cfb, 但支持aes-256-gcm。
然后设置浏览器的socks5代理为127.0.0.1:1080,即可翻墙。
项目地址:https://github.com/zonyitoo/shadowsocks-rust
(https://github.com/loggerhead/shadowsocks-rust,
https://github.com/loggerhead/shadowsocks-rust/issues/7)
-------------
如果你的linux vps的内存太少,编译shadowsocks-rust可能会失败,那么就直接下载它的可执行文件,拿来用即可:
wget https://github.com/shadowsocks/shadowsocks-rust/releases/download/v1.6.10/shadowsocks-v1.6.10-release.x86_64-unknown-linux-musl.tar.xz
tar Jxvf shadowsocks-v1.6.10-release.x86_64-unknown-linux-musl.tar.xz
显示:
sslocal
ssserver
ssurl
root@RegalMusty-VM:~# ./ssserver -c config.json
https://github.com/shadowsocks/shadowsocks-rust/releases
------
https://github.com/ZiJiaW/shadowsocks-rs-simplified