96 lines
2.8 KiB
Ruby
96 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/releases/download/v3.2.0/shadowsocks-libev-3.2.0.tar.gz"
|
|
sha256 "5521cf623a07fd1e393528516a83acd2b66c5d4bb4535a52662806a6a060c606"
|
|
revision 1
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "e654f0ca835ad618255bfb430491abfbe5254d496b79765729b1e0f212679d3c" => :mojave
|
|
sha256 "5b9bb640113ecfd9426b55339404d1c064ffbbaefaf2678d9c2dd2f17f4aac36" => :high_sierra
|
|
sha256 "6945b5311692ffefa6fac0fd421e83067d90eec3bf5d13e0b33878789392aa80" => :sierra
|
|
sha256 "226e9842234e7a323a3264cef3f7141fd99e8b71f06374a573cc21751c0815dd" => :el_capitan
|
|
end
|
|
|
|
depends_on "asciidoc" => :build
|
|
depends_on "xmlto" => :build
|
|
depends_on "c-ares"
|
|
depends_on "libev"
|
|
depends_on "libsodium"
|
|
depends_on "mbedtls"
|
|
depends_on "pcre"
|
|
|
|
def install
|
|
ENV["XML_CATALOG_FILES"] = etc/"xml/catalog"
|
|
|
|
system "./configure", "--prefix=#{prefix}"
|
|
system "make"
|
|
|
|
(buildpath/"shadowsocks-libev.json").write <<~EOS
|
|
{
|
|
"server":"localhost",
|
|
"server_port":8388,
|
|
"local_port":1080,
|
|
"password":"barfoo!",
|
|
"timeout":600,
|
|
"method":null
|
|
}
|
|
EOS
|
|
etc.install "shadowsocks-libev.json"
|
|
|
|
inreplace Dir["man/*"], "/etc/shadowsocks-libev/config.json", "#{etc}/shadowsocks-libev.json"
|
|
|
|
system "make", "install"
|
|
end
|
|
|
|
plist_options :manual => "#{HOMEBREW_PREFIX}/opt/shadowsocks-libev/bin/ss-local -c #{HOMEBREW_PREFIX}/etc/shadowsocks-libev.json -u"
|
|
|
|
def plist; <<~EOS
|
|
<?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>
|
|
<string>-u</string>
|
|
</array>
|
|
<key>RunAtLoad</key>
|
|
<true/>
|
|
<key>KeepAlive</key>
|
|
<true/>
|
|
</dict>
|
|
</plist>
|
|
EOS
|
|
end
|
|
|
|
test do
|
|
(testpath/"shadowsocks-libev.json").write <<~EOS
|
|
{
|
|
"server":"127.0.0.1",
|
|
"server_port":9998,
|
|
"local":"127.0.0.1",
|
|
"local_port":9999,
|
|
"password":"test",
|
|
"timeout":600,
|
|
"method":null
|
|
}
|
|
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
|
|
end
|