-
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-7188",
revision: "a354071dd0b0bc13069841e931ab1ce3b32b7906"
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: "cdc198a26d4151e1f200098b6410b4fbb23877bb60d6da9078279845e0cd9cc6"
sha256 cellar: :any_skip_relocation, arm64_sonoma: "8698f57bc3ccf46dd00145f9b3e945bad059b7680f4cdd8b1f8c64d66de6a84a"
sha256 cellar: :any_skip_relocation, ventura: "01406a69de5f0e9cc18749c66b4e94589dc16120358cfb19241bd5ea7a2ab023"
sha256 cellar: :any_skip_relocation, x86_64_linux: "9a35aca645ba7f75168695b9ec02fca497bb1c84c29cc99fd9dcceb0fb07d07b"
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