mirror of
https://github.com/shadowsocks/shadowsocks-rust.git
synced 2026-02-09 01:59:16 +08:00
@@ -1,27 +1,71 @@
|
||||
class ShadowsocksRust < Formula
|
||||
desc "shadowsocks is a fast tunnel proxy that helps you bypass firewalls"
|
||||
homepage "https://github.com/shadowsocks/shadowsocks-rust"
|
||||
url "https://github.com/shadowsocks/shadowsocks-rust/archive/refs/tags/v1.10.5.tar.gz"
|
||||
version "1.10.5"
|
||||
sha256 "00fb90b6f80d01c6b40f6cfeb49d70fbec9f659bfa268d6834e79fe1f670d55e"
|
||||
license "MIT"
|
||||
desc "Rust port of Shadowsocks"
|
||||
homepage "https://github.com/shadowsocks/shadowsocks-rust"
|
||||
url "https://github.com/shadowsocks/shadowsocks-rust/archive/v1.15.0-alpha.9.tar.gz"
|
||||
sha256 "8c32521c847c4535bb9c496600c8323e4fc4ce1b7ee1cf5e54d17109837acb79"
|
||||
license "MIT"
|
||||
head "https://github.com/shadowsocks/shadowsocks-rust.git", branch: "master"
|
||||
|
||||
head do
|
||||
url "https://github.com/shadowsocks/shadowsocks-rust.git"
|
||||
end
|
||||
|
||||
depends_on "rust" => :build
|
||||
|
||||
def install
|
||||
ENV.with_build_environment do
|
||||
ENV["RUSTFLAGS"] = "-C target-cpu=native"
|
||||
system "cargo", "install", *std_cargo_args, "--features", "local-tun local-redir"
|
||||
end
|
||||
end
|
||||
|
||||
test do
|
||||
system bin/"sslocal", "--help"
|
||||
system bin/"ssserver", "--help"
|
||||
system bin/"ssmanager", "--help"
|
||||
end
|
||||
depends_on "rust" => :build
|
||||
|
||||
def install
|
||||
system "cargo", "install", *std_cargo_args
|
||||
(buildpath/"shadowsocks-rust.json").write <<~EOS
|
||||
{
|
||||
"server":"localhost",
|
||||
"server_port":8388,
|
||||
"password":"barfoo!",
|
||||
"timeout":600,
|
||||
"acl": "/usr/local/etc/chn.acl",
|
||||
"locals": [
|
||||
{
|
||||
"protocol": "socks",
|
||||
"local_address": "127.0.0.1",
|
||||
"local_port": 1080
|
||||
},
|
||||
{
|
||||
"protocol": "http",
|
||||
"local_address": "127.0.0.1",
|
||||
"local_port": 3128
|
||||
}
|
||||
]
|
||||
}
|
||||
EOS
|
||||
etc.install "shadowsocks-rust.json"
|
||||
end
|
||||
|
||||
service do
|
||||
run [opt_bin/"sslocal", "--config", etc/"shadowsocks-rust.json"]
|
||||
keep_alive true
|
||||
end
|
||||
|
||||
test do
|
||||
server_port = free_port
|
||||
local_port = free_port
|
||||
|
||||
(testpath/"server.json").write <<~EOS
|
||||
{
|
||||
"server":"127.0.0.1",
|
||||
"server_port":#{server_port},
|
||||
"password":"mypassword",
|
||||
"method":"aes-256-gcm"
|
||||
}
|
||||
EOS
|
||||
(testpath/"local.json").write <<~EOS
|
||||
{
|
||||
"server":"127.0.0.1",
|
||||
"server_port":#{server_port},
|
||||
"password":"mypassword",
|
||||
"method":"aes-256-gcm",
|
||||
"local_address":"127.0.0.1",
|
||||
"local_port":#{local_port}
|
||||
}
|
||||
EOS
|
||||
fork { exec bin/"ssserver", "-c", testpath/"server.json" }
|
||||
fork { exec bin/"sslocal", "-c", testpath/"local.json" }
|
||||
sleep 3
|
||||
|
||||
output = shell_output "curl --socks5 127.0.0.1:#{local_port} https://example.com"
|
||||
assert_match "Example Domain", output
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user