blob: 0af30c7c6903f20f97d73de9d034ed592dcfd119 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
  | 
require "formula"
class ShadowsocksLibev < Formula
  homepage "https://github.com/madeye/shadowsocks-libev"
  url "https://github.com/madeye/shadowsocks-libev/archive/v1.5.3.tar.gz"
  sha1 "afb285b8d84bea44f4f844f00907f139c321b2e4"
  bottle do
    sha1 "505df68f724008fb39b064763cb3d06ac0c9a0ee" => :yosemite
    sha1 "0fa41d7494b08853bbe93a6fdc59b5f9f2933807" => :mavericks
    sha1 "98ca1d724966abd78e1a44977598109b54c69e82" => :mountain_lion
  end
  head "https://github.com/madeye/shadowsocks-libev.git"
  option "with-polarssl", "Use PolarSSL instead of OpenSSL"
  depends_on "polarssl" => :optional
  depends_on "openssl" if build.without? "polarssl"
  def install
    args = ["--prefix=#{prefix}"]
    if build.with? "polarssl"
      polarssl = Formula["polarssl"]
      args << "--with-crypto-library=polarssl"
      args << "--with-polarssl=#{polarssl.opt_prefix}"
    end
    system "./configure", *args
    system "make"
    bin.install "src/ss-local"
    (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"
    inreplace "shadowsocks.8", "/etc/shadowsocks/config.json", "#{etc}/shadowsocks-libev.json"
    man8.install "shadowsocks.8"
  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
  |