Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 68 additions & 24 deletions homebrew/shadowsocks-rust.rb
Original file line number Diff line number Diff line change
@@ -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