|
1 | 1 | class ShadowsocksRust < Formula
|
2 |
| - desc "shadowsocks is a fast tunnel proxy that helps you bypass firewalls" |
3 |
| - homepage "https://github.com/shadowsocks/shadowsocks-rust" |
4 |
| - url "https://github.com/shadowsocks/shadowsocks-rust/archive/refs/tags/v1.10.5.tar.gz" |
5 |
| - version "1.10.5" |
6 |
| - sha256 "00fb90b6f80d01c6b40f6cfeb49d70fbec9f659bfa268d6834e79fe1f670d55e" |
7 |
| - license "MIT" |
| 2 | + desc "Rust port of Shadowsocks" |
| 3 | + homepage "https://github.com/shadowsocks/shadowsocks-rust" |
| 4 | + url "https://github.com/shadowsocks/shadowsocks-rust/archive/v1.15.0-alpha.9.tar.gz" |
| 5 | + sha256 "8c32521c847c4535bb9c496600c8323e4fc4ce1b7ee1cf5e54d17109837acb79" |
| 6 | + license "MIT" |
| 7 | + head "https://github.com/shadowsocks/shadowsocks-rust.git", branch: "master" |
8 | 8 |
|
9 |
| - head do |
10 |
| - url "https://github.com/shadowsocks/shadowsocks-rust.git" |
11 |
| - end |
12 |
| - |
13 |
| - depends_on "rust" => :build |
14 |
| - |
15 |
| - def install |
16 |
| - ENV.with_build_environment do |
17 |
| - ENV["RUSTFLAGS"] = "-C target-cpu=native" |
18 |
| - system "cargo", "install", *std_cargo_args, "--features", "local-tun local-redir" |
19 |
| - end |
20 |
| - end |
21 |
| - |
22 |
| - test do |
23 |
| - system bin/"sslocal", "--help" |
24 |
| - system bin/"ssserver", "--help" |
25 |
| - system bin/"ssmanager", "--help" |
26 |
| - end |
| 9 | + depends_on "rust" => :build |
| 10 | + |
| 11 | + def install |
| 12 | + system "cargo", "install", *std_cargo_args |
| 13 | + (buildpath/"shadowsocks-rust.json").write <<~EOS |
| 14 | + { |
| 15 | + "server":"localhost", |
| 16 | + "server_port":8388, |
| 17 | + "password":"barfoo!", |
| 18 | + "timeout":600, |
| 19 | + "acl": "/usr/local/etc/chn.acl", |
| 20 | + "locals": [ |
| 21 | + { |
| 22 | + "protocol": "socks", |
| 23 | + "local_address": "127.0.0.1", |
| 24 | + "local_port": 1080 |
| 25 | + }, |
| 26 | + { |
| 27 | + "protocol": "http", |
| 28 | + "local_address": "127.0.0.1", |
| 29 | + "local_port": 3128 |
| 30 | + } |
| 31 | + ] |
| 32 | + } |
| 33 | + EOS |
| 34 | + etc.install "shadowsocks-rust.json" |
| 35 | + end |
| 36 | + |
| 37 | + service do |
| 38 | + run [opt_bin/"sslocal", "--config", etc/"shadowsocks-rust.json"] |
| 39 | + keep_alive true |
| 40 | + end |
| 41 | + |
| 42 | + test do |
| 43 | + server_port = free_port |
| 44 | + local_port = free_port |
| 45 | + |
| 46 | + (testpath/"server.json").write <<~EOS |
| 47 | + { |
| 48 | + "server":"127.0.0.1", |
| 49 | + "server_port":#{server_port}, |
| 50 | + "password":"mypassword", |
| 51 | + "method":"aes-256-gcm" |
| 52 | + } |
| 53 | + EOS |
| 54 | + (testpath/"local.json").write <<~EOS |
| 55 | + { |
| 56 | + "server":"127.0.0.1", |
| 57 | + "server_port":#{server_port}, |
| 58 | + "password":"mypassword", |
| 59 | + "method":"aes-256-gcm", |
| 60 | + "local_address":"127.0.0.1", |
| 61 | + "local_port":#{local_port} |
| 62 | + } |
| 63 | + EOS |
| 64 | + fork { exec bin/"ssserver", "-c", testpath/"server.json" } |
| 65 | + fork { exec bin/"sslocal", "-c", testpath/"local.json" } |
| 66 | + sleep 3 |
| 67 | + |
| 68 | + output = shell_output "curl --socks5 127.0.0.1:#{local_port} https://example.com" |
| 69 | + assert_match "Example Domain", output |
27 | 70 | end
|
| 71 | +end |
0 commit comments