Skip to content

Instantly share code, notes, and snippets.

@foxundermoon
Last active August 11, 2018 18:32
Show Gist options
  • Save foxundermoon/c4f80fc214ea3481bf5ab1e128d75e0a to your computer and use it in GitHub Desktop.
Save foxundermoon/c4f80fc214ea3481bf5ab1e128d75e0a to your computer and use it in GitHub Desktop.
class Kcptun < Formula
desc "Kcptun for speed up shadowsocks"
homepage "https://github.com/xtaci/kcptun"
url "https://github.com/xtaci/kcptun/releases/download/v20180810/kcptun-darwin-amd64-20180810.tar.gz"
sha256 "d7712c773d04e1b79a36e8a277860d68a6effc061daefe67d97c3357692b26e3"
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
def install
# ENV["XML_CATALOG_FILES"] = etc/"xml/catalog"
#
# system "./configure", "--prefix=#{prefix}"
# system "make"
# (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"
bin.install "client_darwin_amd64"
# inreplace Dir["man/*"], "/etc/shadowsocks-libev/config.json", "#{etc}/shadowsocks-libev.json"
# system "make", "install"
end
plist_options :startup => true
plist_options :manual => "#{HOMEBREW_PREFIX}/Cellar/kcptun/20180810/bin/client_darwin_amd64 -r vps.vvfox.com:8384 -l 0.0.0.0:8384 -mode fast3"
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>#{bin}/client_darwin_amd64</string>
<string>-r</string>
<string>vps.vvfox.com:8384</string>
<string>-l</string>
<string>0.0.0.0:8384</string>
<string>-mode</string>
<string>fast3</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
EOS
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
client = fork { exec "#{HOMEBREW_PREFIX}/Cellar/kcptun/20180810/bin/client_darwin_amd64", "-r", "vps.vvfox.com:8384", "-l", "0.0.0.0:8384", "-mode", "fast3" }
# client = fork { exec bin/"ss-local", "-c", testpath/"shadowsocks-libev.json" }
sleep 3
begin
system "lsof", "-i:8384"
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment