分享一个去年用 rust 实现的 shadowsocks-演道网
2017 年 1 月 3 日
去年入了 rust 的坑,找了 shadowsocks 作为练手项目,现在完成得差不多了,分享给大家:
https://github.com/loggerhead/shadowsocks-rust
特点
. | Rust | Python (2.9.0) |
---|---|---|
支持 UDP 代理 | √ | √ |
TCP fast open | 暂不支持 | √ |
支持 IP 黑名单 | X | √ |
One time auth | √ | √ |
支持多种加密方式 | √ | √ |
异步 UDP 支持 | √ | X |
支持 IPv6 | 未测试 | X |
兼容 Windows | 有 bug | 需要安装 OpenSSL |
多服务器支持 | √ | X |
不依赖 OpenSSL 的情况下,支持以下加密方式:
- aes-128-ctr
- aes-192-ctr
- aes-256-ctr
- rc4
- hc128
- salsa20
- xsalsa20
- chacha20
- xchacha20
- sosemanuk
安装
运行下面这行命令会自动安装 sslocal
和 ssserver
:
curl https://raw.githubusercontent.com/loggerhead/shadowsocks-rust/master/build.sh -sSf | sh
也可以通过 docker
安装 ssserver
:
docker pull loggerhead/shadowsocks-rust
或者通过 cargo
安装 ssserver
:
cargo install shadowsocks
运行
- 在 VPS 上运行命令
ssserver
自动生成配置,并记录下生成的配置码,如:ss://XXX
- 在本机运行命令
sslocal ss://XXX
即可
配置
配置采用的是 TOML,不是 JSON ,但是也相当简单。比如,一个典型的 sslocal
的配置是这样的:
# tests/config/rs_local.toml
port = 8010
password = "foo"
timeout = 60
method = "aes-256-cfb"
one_time_auth = false
# 支持多服务器
[[servers]]
address = "localhost.loggerhead.me"
port = 8111
[[servers]]
address = "example.com"
port = 1234
method = "rc4"
password = "bar"
意思是监听本地 8010 端口,默认的加密方式是 “aes-256-cfb”,也就是下图所示:
sslocal ssserver
8010 --------> localhost.loggerhead.me:8111 aes-256-cfb
|
+-----> example.com:1234 rc4
ssserver
的配置是这样的:
address = "127.0.0.1"
port = 8111
password = "foo"
timeout = 60
method = "aes-256-cfb"
one_time_auth = false
新年计划 ?
- 支持 HTTP 代理
- 兼容 windows
- 交叉编译在 OpenWrt 上运行
转载自演道,想查看更及时的互联网产品技术热点文章请点击http://go2live.cn