-
-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Expand file tree
/
Copy pathxray.rb
More file actions
108 lines (95 loc) · 3.4 KB
/
Copy pathxray.rb
File metadata and controls
108 lines (95 loc) · 3.4 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
class Xray < Formula
desc "Platform for building proxies to bypass network restrictions"
homepage "https://xtls.github.io/"
url "https://github.com/XTLS/Xray-core/archive/refs/tags/v26.2.6.tar.gz"
sha256 "a41f170a03fa25d9d39f23f344540b02336a5c893d97b1b837b9477f4b35bc7f"
license all_of: ["MPL-2.0", "CC-BY-SA-4.0"]
head "https://github.com/XTLS/Xray-core.git", branch: "main"
livecheck do
url :stable
strategy :github_latest
end
bottle do
sha256 cellar: :any_skip_relocation, arm64_tahoe: "c22ec3819c838dabeae55832a8e0620ec5083bdfd39e3b597befae66497107c7"
sha256 cellar: :any_skip_relocation, arm64_sequoia: "c22ec3819c838dabeae55832a8e0620ec5083bdfd39e3b597befae66497107c7"
sha256 cellar: :any_skip_relocation, arm64_sonoma: "c22ec3819c838dabeae55832a8e0620ec5083bdfd39e3b597befae66497107c7"
sha256 cellar: :any_skip_relocation, sonoma: "fe5a97770664f76e2c6eee217596e9e53f59f4402623939836a346fe5c826d1c"
sha256 cellar: :any_skip_relocation, arm64_linux: "14d1323588a84aeede5dbb5eff4a71d01c3653dbea1c2e9220b852765c7243c1"
sha256 cellar: :any_skip_relocation, x86_64_linux: "6e5f1127941eef85994d37ea2b23b7297aeece81cdb95dff12da40f26212e48e"
end
depends_on "go" => :build
resource "geoip" do
url "https://github.com/v2fly/geoip/releases/download/202601220433/geoip.dat"
sha256 "ed2de9add79623e2e5dbc5930ee39cc7037a7c6e0ecd58ba528b6f73d61457b5"
end
resource "geosite" do
url "https://github.com/v2fly/domain-list-community/releases/download/20260203145437/dlc.dat"
sha256 "158e0e3052238dcdd09d58857032c67da49b933b3a9fd74fedf2c684e21d4f87"
end
resource "example_config" do
# borrow v2ray example config
url "https://raw.githubusercontent.com/v2fly/v2ray-core/v5.44.1/release/config/config.json"
sha256 "15a66415d72df4cd77fcd037121f36604db244dcfa7d45d82a0c33de065c6a87"
livecheck do
url "https://github.com/v2fly/v2ray-core.git"
end
end
def install
ldflags = "-s -w -buildid="
execpath = libexec/name
system "go", "build", *std_go_args(output: execpath, ldflags:), "./main"
(bin/"xray").write_env_script execpath,
XRAY_LOCATION_ASSET: "${XRAY_LOCATION_ASSET:-#{pkgshare}}"
pkgshare.install resource("geoip")
resource("geosite").stage do
pkgshare.install "dlc.dat" => "geosite.dat"
end
pkgetc.install resource("example_config")
end
def caveats
<<~EOS
An example config is installed to #{etc}/xray/config.json
EOS
end
service do
run [opt_bin/"xray", "run", "--config", "#{etc}/xray/config.json"]
run_type :immediate
keep_alive true
end
test do
(testpath/"config.json").write <<~JSON
{
"log": {
"access": "#{testpath}/log"
},
"outbounds": [
{
"protocol": "freedom",
"tag": "direct"
}
],
"routing": {
"rules": [
{
"ip": [
"geoip:private"
],
"outboundTag": "direct",
"type": "field"
},
{
"domains": [
"geosite:private"
],
"outboundTag": "direct",
"type": "field"
}
]
}
}
JSON
output = shell_output "#{bin}/xray -c #{testpath}/config.json -test"
assert_match "Configuration OK", output
assert_path_exists testpath/"log"
end
end