-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathneon-proxy.rb
87 lines (75 loc) · 2.37 KB
/
neon-proxy.rb
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
79
80
81
82
83
84
85
86
87
class NeonProxy < Formula
desc "Proxy for Neon"
homepage "https://github.com/neondatabase/neon"
url "https://github.com/neondatabase/neon.git",
tag: "release-proxy-7586",
revision: "23352dc2e9a2c1de705625f1b02f2f02a6dbf67f"
license "Apache-2.0"
head "https://github.com/neondatabase/neon.git", branch: "main"
livecheck do
url :head
regex(/^release-proxy-(\d+)$/i)
end
bottle do
root_url "https://ghcr.io/v2/bayandin/tap"
sha256 cellar: :any_skip_relocation, arm64_sequoia: "7247d7751eac859f390e5571a84c4802cf36a6988d2baf8a1a3eb93aecc730c5"
sha256 cellar: :any_skip_relocation, arm64_sonoma: "a94a9b59224cb6108a2e8632fc1436e841ae3fe769dd04d0c5b82fc50ca448e6"
sha256 cellar: :any_skip_relocation, ventura: "0292f7b84d1d0a7421b0e24078ddea825637da6a2ae913aed14764b7ff261018"
sha256 cellar: :any_skip_relocation, x86_64_linux: "52a2528e7fe28e8c38d3ee0ac1ec9d4224ff2ee9146ecb60eb6adaf3291149d8"
end
depends_on "rust" => :build
depends_on "openssl@3"
uses_from_macos "llvm" => :build
def install
ENV["BUILD_TAG"] = build.stable? ? "release-proxy-#{version}" : "dev-#{Utils.git_short_head}"
ENV["GIT_VERSION"] = Utils.git_head
args = std_cargo_args(root: libexec, path: "proxy") + %w[
--features testing
]
system "cargo", "install", *args
(bin/"neon-proxy").write <<~EOS
#!/bin/bash
CERTS_DIR="#{var}/neon-proxy/certs"
for arg in "$@"; do
case "$arg" in
"--tls-cert" | "-c" | "--tls-key" | "-k" | "--certs-dir")
CERTS_DIR=""
;;
*)
;;
esac
done
if [ -n "${CERTS_DIR}" ]; then
exec "#{libexec}/bin/proxy" --certs-dir="${CERTS_DIR}" "$@"
else
exec "#{libexec}/bin/proxy" "$@"
fi
EOS
end
def post_install
certs_dir = var/"neon-proxy/certs"
return if (certs_dir/"tls.crt").exist? && (certs_dir/"/tls.key").exist?
mkdir_p certs_dir
args = [
"req",
"-new",
"-x509",
"-days",
"365",
"-nodes",
"-text",
"-out",
"#{certs_dir}/tls.crt",
"-keyout",
"#{certs_dir}/tls.key",
"-subj",
"/CN=*.localtest.me",
"-addext",
"subjectAltName = DNS:*.localtest.me",
]
system Formula["openssl@3"].opt_bin/"openssl", *args
end
test do
system bin/"neon-proxy", "--version"
end
end