v2ray-rules-dat/generate-rules-dat.sh

57 lines
1.9 KiB
Bash
Raw Normal View History

2019-12-10 15:40:58 +08:00
#!/usr/bin/env bash
set -e
GREEN='\033[0;32m'
NC='\033[0m' # no color
2019-12-11 02:43:22 +08:00
export GOPATH=${GITHUB_WORKSPACE}
2019-12-10 15:40:58 +08:00
V2RAY_FOLDER="$GOPATH/v2ray"
2019-12-10 16:45:51 +08:00
mkdir -p $V2RAY_FOLDER
2019-12-10 15:40:58 +08:00
GEOIP_REPO="github.com/ilouiss/geoip"
GEOSITE_REPO="github.com/v2ray/domain-list-community"
getGFWLIST_SCRIPT="https://raw.githubusercontent.com/cokebar/gfwlist2dnsmasq/master/gfwlist2dnsmasq.sh"
CHINA_DOMAINS_URL="https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/accelerated-domains.china.conf"
ADBLOCK_DOMAINS_URL="https://raw.githubusercontent.com/h2y/Shadowrocket-ADBlock-Rules/master/factory/resultant/ad.list"
echo -e "${GREEN}>>> downloading $GEOIP_REPO...${NC}"
go get -insecure -v -u -d $GEOIP_REPO
cd $GOPATH/src/$GEOIP_REPO
echo -e "${GREEN}>>> building geoip.dat file...${NC}"
go run main.go
mv geoip.dat $V2RAY_FOLDER/geoip.dat
2019-12-10 16:56:49 +08:00
echo -e "${GREEN}>>> Finished geoip.dat ${NC}"
2019-12-10 15:40:58 +08:00
echo -e "${GREEN}>>> downloading $GEOSITE_REPO...${NC}"
go get -insecure -v -u -d $GEOSITE_REPO
cd $GOPATH/src/$GEOSITE_REPO
echo -e "${GREEN}>>> generating GFWList...${NC}"
curl -sSL $getGFWLIST_SCRIPT \
| bash -s -- -l -o $GOPATH/src/$GEOSITE_REPO/data/gfwlist
2019-12-10 16:56:49 +08:00
echo -e "${GREEN}>>> Finished GFWList ${NC}"
2019-12-10 15:40:58 +08:00
echo -e "${GREEN}>>> generating Chinese domains list...${NC}"
curl -sSL $CHINA_DOMAINS_URL \
| awk -F '/' '{print $2}' \
> $GOPATH/src/$GEOSITE_REPO/data/chinalist
2019-12-10 16:56:49 +08:00
echo -e "${GREEN}>>> Finished Chinalist ${NC}"
2019-12-10 15:40:58 +08:00
2019-12-11 03:31:13 +08:00
echo -e "${GREEN}>>> generating AdBlock domains list...${NC}"
curl -sSL $ADBLOCK_DOMAINS_URL \
| grep -eov '^(\d{1,3}\.){3}\d{1,3}' \
| grep -eov '^[^.]$' \
> $GOPATH/src/$GEOSITE_REPO/data/adblocklist
# | grep -eo '^(([a-zA-Z0-9]+[a-zA-Z0-9-]*)+\.)+[a-zA-Z0-9]{2,}$' \
echo -e "${GREEN}>>> Finished AdBlocklist ${NC}"
2019-12-10 15:40:58 +08:00
echo -e "${GREEN}>>> building geosite.dat file...${NC}"
go run main.go
mv dlc.dat $V2RAY_FOLDER/geosite.dat
2019-12-10 16:56:49 +08:00
echo -e "${GREEN}>>> Finished geosite.dat ${NC}"
2019-12-10 15:40:58 +08:00
echo -e "${GREEN}完成啦!🌈${NC}"