Skip to content

Instantly share code, notes, and snippets.

@foxundermoon
Last active August 11, 2018 19:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save foxundermoon/93df2244eec5c5cea09a4ba362be963e to your computer and use it in GitHub Desktop.
Save foxundermoon/93df2244eec5c5cea09a4ba362be963e to your computer and use it in GitHub Desktop.
class ShadowsocksKcp < Formula
@name="shadowsocks-kcp"
desc "Kcptun for speed up shadowsocks"
# homepage "https://github.com/xtaci/kcptun"
# url "https://github.com/xtaci/kcptun/releases/download/v20161207/kcptun-darwin-amd64-20161207.tar.gz"
# url "http://data.vvfox.com/tools/shadowsocks-kcp-1.0.0.tar"
# sha256 "751f79884e83510d6052f6d04908115f6e141b779f2b00882e4019ea2b0bbd58"
# head "https://github.com/xtaci/kcptun.git"
# bottle do
# cellar :any
# sha256 "751f79884e83510d6052f6d04908115f6e141b779f2b00882e4019ea2b0bbd58" => :sierra
# sha256 "751f79884e83510d6052f6d04908115f6e141b779f2b00882e4019ea2b0bbd58" => :el_capitan
# sha256 "751f79884e83510d6052f6d04908115f6e141b779f2b00882e4019ea2b0bbd58" => :yosemite
# end
# depends_on "asciidoc" => :build
# depends_on "xmlto" => :build
# depends_on "openssl"
# depends_on "pcre"
depends_on "shadowsocks-libev" => :run
depends_on "kcptun" => :run
def install
# ENV["XML_CATALOG_FILES"] = etc/"xml/catalog"
#
# system "./configure", "--prefix=#{prefix}"
# system "make"
"#{etc}/#{@name}.json".write <<~EOS
{
"server":"localhost",
"server_port":8384,
"local_port":4385,
"local_address":"0.0.0.0",
"password":"vvfox",
"timeout":600,
"method":"aes-128-cfb"
}
EOS
# bin.install "#{@name}.sh"
# etc.install "#{@name}.json"
# bin.install "client_darwin_amd64"
# inreplace Dir["man/*"], "/etc/#{@name}/config.json", "#{etc}/#{@name}.json"
# system "make", "install"
end
# kcptun = Formula["kcptun"]
# kcp_bin=kcptun.bin
plist_options :startup => false
plist_options :manual => "#{Formula["shadowsocks-libev"].bin}/ss-local -c #{HOMEBREW_PREFIX}/etc/#{@name}.json"
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>#{Formula["shadowsocks-libev"].bin}/ss-local</string>
<string>-c</string>
<string>#{etc}/#{@name}.json</string>
</array>
<key>RunAtLoad</key>
<false/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
EOS
end
test do
(testpath/"#{@name}.json").write <<~EOS
{
"server":"localhost",
"server_port":8384,
"local_port":4385,
"local_address":"0.0.0.0",
"password":"vvfox",
"timeout":600,
"method":"aes-128-cfb"
}
EOS
# server = fork { exec bin/"ss-server", "-c", testpath/"shadowsocks-libev.json" }
client = fork { exec "#{Formula["shadowsocks-libev"].bin}/ss-local", "-c", testpath/"#{@name}.json" }
sleep 3
begin
system "curl", "--socks5", "127.0.0.1:4385", "google.com"
ensure
# Process.kill 9, server
# Process.wait server
Process.kill 9, client
Process.wait client
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment