94 lines
2.8 KiB
Ruby
94 lines
2.8 KiB
Ruby
class ShadowsocksLibev < Formula
|
|
desc "Libev port of shadowsocks"
|
|
homepage "https://github.com/shadowsocks/shadowsocks-libev"
|
|
url "https://github.com/shadowsocks/shadowsocks-libev/archive/v2.4.0.tar.gz"
|
|
sha256 "80e55840e4e3fb61f9ec13b2cad75acb1f5a39212a5141ff5751c6a147a3218b"
|
|
head "https://github.com/shadowsocks/shadowsocks-libev.git"
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "1443f6eef1c4984f458907168beef526c1172fa4f3df54c8880748e44aefa005" => :el_capitan
|
|
sha256 "cd1dde0eaec1c872c098b33dc540902693803fc85e2242d41720b3578f97fa3c" => :yosemite
|
|
sha256 "f87760e9d3e366bc4f81d0e129db617c13378b9f1fb4fca6a674956362eb158d" => :mavericks
|
|
end
|
|
|
|
depends_on "openssl"
|
|
|
|
def install
|
|
args = ["--prefix=#{prefix}"]
|
|
|
|
system "./configure", *args
|
|
system "make"
|
|
|
|
bin.install "src/ss-local", "src/ss-tunnel", "src/ss-server", "src/ss-manager"
|
|
|
|
(buildpath/"shadowsocks-libev.json").write <<-EOS.undent
|
|
{
|
|
"server":"localhost",
|
|
"server_port":8388,
|
|
"local_port":1080,
|
|
"password":"barfoo!",
|
|
"timeout":600,
|
|
"method":null
|
|
}
|
|
EOS
|
|
etc.install "shadowsocks-libev.json"
|
|
|
|
rm "man/ss-redir.1"
|
|
inreplace Dir["man/*"], "/etc/shadowsocks-libev/config.json", "#{etc}/shadowsocks-libev.json"
|
|
man8.install Dir["man/*.8"]
|
|
man1.install Dir["man/*.1"]
|
|
end
|
|
|
|
test do
|
|
(testpath/"shadowsocks-libev.json").write <<-EOS.undent
|
|
{
|
|
"server":"127.0.0.1",
|
|
"server_port":9998,
|
|
"local":"127.0.0.1",
|
|
"local_port":9999,
|
|
"password":"test",
|
|
"timeout":600,
|
|
"method":"table"
|
|
}
|
|
EOS
|
|
server = fork { exec bin/"ss-server", "-c", testpath/"shadowsocks-libev.json" }
|
|
client = fork { exec bin/"ss-local", "-c", testpath/"shadowsocks-libev.json" }
|
|
sleep 3
|
|
begin
|
|
system "curl", "--socks5", "127.0.0.1:9999", "github.com"
|
|
ensure
|
|
Process.kill 9, server
|
|
Process.wait server
|
|
Process.kill 9, client
|
|
Process.wait client
|
|
end
|
|
end
|
|
|
|
plist_options :manual => "#{HOMEBREW_PREFIX}/opt/shadowsocks-libev/bin/ss-local -c #{HOMEBREW_PREFIX}/etc/shadowsocks-libev.json"
|
|
|
|
def plist; <<-EOS.undent
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
<plist version="1.0">
|
|
<dict>
|
|
<key>Label</key>
|
|
<string>#{plist_name}</string>
|
|
<key>ProgramArguments</key>
|
|
<array>
|
|
<string>#{opt_bin}/ss-local</string>
|
|
<string>-c</string>
|
|
<string>#{etc}/shadowsocks-libev.json</string>
|
|
</array>
|
|
<key>RunAtLoad</key>
|
|
<true/>
|
|
<key>KeepAlive</key>
|
|
<dict>
|
|
<key>SuccessfulExit</key>
|
|
<false/>
|
|
</dict>
|
|
</dict>
|
|
</plist>
|
|
EOS
|
|
end
|
|
end
|