Skip to content

Commit 1d8516b

Browse files
committed
Add release building support in Makefile
Signed-off-by: Guorui Yu <yuguorui96@gmail.com>
1 parent 0731290 commit 1d8516b

File tree

4 files changed

+78
-6
lines changed

4 files changed

+78
-6
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
target/
22
config.*ml
33
*.mmdb
4+
geoip.dat
5+
geosite.dat
46
src/protos/common.rs
5-
.gitback/
7+
.gitback/
8+
rfor-*.tar.gz

Makefile

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,40 @@
11
SRC_DIR := ./src
22
SRC_FILES := $(wildcard $(SRC_DIR)/*.rs)
3-
TARGET_FILE := target/x86_64-unknown-linux-musl/debug/rfor
43

4+
mode=debug
55
ifeq ($(release),1)
66
flag=--release
7+
mode=release
78
endif
89

9-
rfor: TARGET_FILE
10+
arch := $(shell uname -m)
11+
TARGET_FILE := target/$(arch)-unknown-linux-musl/$(mode)/rfor
12+
version = $(shell grep -E ^version Cargo.toml | tr -d '"'| cut -d " " -f 3)
1013

11-
TARGET_FILE: $(SRC_FILES) Cargo.toml
12-
RUSTFLAGS='-C target-feature=+crt-static' cargo build $(flag) --target x86_64-unknown-linux-musl
14+
rfor: $(TARGET_FILE)
15+
16+
$(TARGET_FILE): $(SRC_FILES) Cargo.toml
17+
RUSTFLAGS='-C target-feature=+crt-static' cargo build $(flag) --target $(arch)-unknown-linux-musl
18+
19+
geoip.dat:
20+
wget https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/geoip.dat
21+
22+
geosite.dat:
23+
wget https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat
24+
25+
release: geoip.dat geosite.dat $(TARGET_FILE)
26+
export temp_dir=$(shell mktemp -d); \
27+
export artifact_name=rfor-$(version)-linux-$(arch)-$(mode); \
28+
mkdir -p $$temp_dir/$$artifact_name; \
29+
cp -a geoip.dat geosite.dat $$temp_dir/$$artifact_name; \
30+
cp -a conf/* $$temp_dir/$$artifact_name; \
31+
cp -a $(TARGET_FILE) $$temp_dir/$$artifact_name; \
32+
tar czf $$artifact_name.tar.gz -C $$temp_dir $$artifact_name; \
33+
rm -rf $$temp_dir
1334

1435
clean:
1536
@cargo clean
37+
@rm -f geoip.dat
38+
@rm -f geosite.dat
1639

17-
.PHONY: rfor clean
40+
.PHONY: rfor clean release

conf/config-cn.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
tproxy-listen: '[::]:50080'
2+
socks5-listen: '[::]:1081'
3+
4+
outbounds:
5+
- name: DROP
6+
url: drop://0.0.0.0
7+
- name: PROXY
8+
url: socks5://127.0.0.1:1080
9+
- name: DIRECT
10+
bind_range:
11+
- 2000::/3
12+
13+
traffic-intercept:
14+
mode: auto
15+
local-traffic: true
16+
ports: [22,80,443,465,587,993,8080,9001,9030]
17+
18+
rules:
19+
- DEFAULT,,PROXY
20+
- GEOSITE,geosite.dat:cn,DIRECT
21+
- GEOSITE,geosite.dat:google,PROXY
22+
- GEOSITE,geosite.dat:speedtest,DIRECT
23+
- GEOSITE,geosite.dat:category-ads,DROP

conf/config-redirect.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
debug: false
2+
tproxy-listen: '[::]:50080'
3+
socks5-listen: '[::]:50081'
4+
redirect-listen: '[::]:50082'
5+
6+
traffic-intercept:
7+
mode: redirect # set to "manual" when you want set iptables by hand.
8+
local-traffic: true # set to redirect/tproxy to allow intercept local traffic
9+
ports: [80,443,8080] # ports you are interested
10+
11+
outbounds:
12+
- name: PROXY
13+
url: socks5://192.168.51.1:1080
14+
15+
- name: DIRECT
16+
17+
# It is worth noting that all rules are aggregated in order to improve the speed of rule matching.
18+
# So the matching of rules is not sequential, but declarative. When multiple identical rules exist,
19+
# the matching priority is undefined.
20+
rules:
21+
- DEFAULT,,DIRECT
22+
- DOMAIN-SUFFIX,google.com,PROXY
23+
- DOMAIN,www.google.com,PROXY

0 commit comments

Comments
 (0)