Compare commits

...

16 Commits

Author SHA1 Message Date
eecb11a423 cd to current dir in update script
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2023-11-29 13:49:36 +03:00
066f5207b7 fix for geoip.dat build
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2023-11-16 12:37:23 +03:00
285b619f73 another fix for release build
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2023-11-16 12:24:04 +03:00
68286e9f11 fix for release build
All checks were successful
continuous-integration/drone/push Build is passing
2023-11-16 12:22:13 +03:00
7db6bdaf3d fix for Makefile
Some checks failed
continuous-integration/drone/push Build is failing
2023-11-16 12:19:47 +03:00
bc7e16c009 fix for Makefile 2023-11-16 12:19:27 +03:00
d8e8e891dc use Makefile 2023-11-16 12:19:06 +03:00
ef10f37224 fix for build script 2023-11-16 11:51:11 +03:00
215e4d554d add used projects as submodules 2023-11-16 11:45:15 +03:00
e307a33a13 more events
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is passing
continuous-integration/drone/tag Build is passing
2023-11-15 23:00:01 +03:00
4c5a77f449 truly restore .drone.yml
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2023-11-14 00:14:43 +03:00
c4656f5d37 restore .drone.yml
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2023-11-14 00:11:30 +03:00
7978f723d9 another fix for releases 2023-11-14 00:08:27 +03:00
b5ee87d869 fix for release
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2023-11-14 00:06:02 +03:00
9c12e535d6 weekly releases
All checks were successful
continuous-integration/drone/push Build is passing
2023-11-14 00:01:25 +03:00
f45297afe2 update readme && updater example
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2023-11-11 22:34:30 +03:00
11 changed files with 112 additions and 49 deletions

View File

@ -6,16 +6,16 @@ steps:
- name: generate
image: golang:1.19-alpine
commands:
- apk add --no-cache curl grep libidn sipcalc gawk git patch bash python3
- bash generate.sh
- apk add --no-cache make curl grep libidn sipcalc gawk git patch bash python3
- make all
- name: create release tag
image: alpine:latest
environment:
GITEA_API_KEY:
from_secret: gitea_api_key
commands:
- apk add --no-cache curl
- sh tag.sh
- apk add --no-cache make curl bash
- make release
when:
branch:
- master
@ -25,7 +25,7 @@ steps:
api_key:
from_secret: gitea_api_key
base_url: https://gitea.neur0tx.site
files: .temp/result/*
files: .build/*
checksum:
- sha256
when:
@ -35,4 +35,6 @@ steps:
trigger:
event:
- push
- tag
- tag
- cron
- custom

2
.gitignore vendored
View File

@ -1,2 +1,2 @@
.temp
.build
.tool-versions

9
.gitmodules vendored Normal file
View File

@ -0,0 +1,9 @@
[submodule "antizapret-pac-generator-light"]
path = antizapret-pac-generator-light
url = https://bitbucket.org/anticensority/antizapret-pac-generator-light.git
[submodule "geoip"]
path = geoip
url = https://github.com/v2fly/geoip.git
[submodule "domain-list-community"]
path = domain-list-community
url = https://github.com/v2fly/domain-list-community.git

57
Makefile Normal file
View File

@ -0,0 +1,57 @@
SHELL = /bin/bash -o pipefail
export PATH := $(shell go env GOPATH)/bin:$(PATH)
ROOT_DIR=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
BUILD_DIR=$(ROOT_DIR)/.build
AZ_DIR=$(ROOT_DIR)/antizapret-pac-generator-light
GEOIP_DIR=$(ROOT_DIR)/geoip
GEOSITE_DIR=$(ROOT_DIR)/domain-list-community
DATA_DIR=$(ROOT_DIR)/data
.PHONY: all submodules az geoip geosite release
all: submodules az geoip geosite
@echo Done.
submodules:
@git submodule update --init --recursive
builddir:
ifeq (,$(wildcard $(BUILD_DIR)))
@mkdir -p $(BUILD_DIR)
endif
az: builddir
@bash -c 'set -euo pipefail; \
cd $(AZ_DIR) && \
patch --forward < $(DATA_DIR)/az-cyrillic-idn-fix.patch || true && \
./update.sh && \
./parse.sh'
@echo Antizapret data has been processed.
geoip: builddir
@cat $(DATA_DIR)/geoip-generator-config.json > $(GEOIP_DIR)/config.json
@mkdir -p $(GEOIP_DIR)/data
@cp $(AZ_DIR)/result/iplist_all.txt $(GEOIP_DIR)/data/ru-blocked-ips-all
@cp $(AZ_DIR)/result/iplist_blockedbyip.txt $(GEOIP_DIR)/data/ru-blocked-ips-directblock
@cp $(AZ_DIR)/result/iplist_blockedbyip_noid2971.txt $(GEOIP_DIR)/data/ru-blocked-ips-noid2971
ifeq (,$(wildcard $(GEOIP_DIR)/geoip-src.dat))
@curl -fsSL https://github.com/v2fly/geoip/releases/latest/download/geoip.dat -o $(GEOIP_DIR)/geoip-src.dat
endif
@cd $(GEOIP_DIR) && go run ./
@mv $(GEOIP_DIR)/output/dat/geoip.dat $(BUILD_DIR)/geoip.dat
@echo Built fresh geoip.dat
geosite: builddir
@cp $(AZ_DIR)/result/hostlist_zones.txt $(GEOSITE_DIR)/data/category-ru-blocked-zones
@cp $(AZ_DIR)/result/hostlist_original.txt $(GEOSITE_DIR)/data/category-ru-blocked-domains
@cd $(GEOSITE_DIR) && go run ./ --outputdir=$(BUILD_DIR) --outputname=geosite.dat
@echo Built fresh geosite.dat
VERSION := $(shell date +%Y%m%d%H%M%S)
release:
@echo Tagging as $(VERSION)
@curl -X POST \
https://gitea.neur0tx.site/api/v1/repos/xray-addons/geoip-geosite-with-ru-blocklist/tags?token=${GITEA_API_KEY} \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"message": "$(VERSION): daily release from ci","tag_name": "$(VERSION)","target": "master"}'

View File

@ -1,4 +1,4 @@
# GeoIP & GeoSite with RU blacklist
# GeoIP & GeoSite with RU Blacklist
Generates `geoip.dat` and `geosite.dat` for Xray with additional data:
- Category with sites blocked in Russia (`geosite:category-ru-blocked-domains`).
@ -6,4 +6,22 @@ Generates `geoip.dat` and `geosite.dat` for Xray with additional data:
Data sources:
- [v2fly/geoip](https://github.com/v2fly/geoip) for `geoip.dat`.
- [v2fly/domain-list-community](https://github.com/v2fly/domain-list-community) for `geosite.dat`.
- [v2fly/domain-list-community](https://github.com/v2fly/domain-list-community) for `geosite.dat`.
You can replace original `geoip.dat` and `geosite.dat` with the ones from this repo and route only blocked traffic through the proxy.
# GeoIP Categories
- `geoip:ru-blocked-ips-all` - IP's and IP ranges blocked in Russia.
- `geoip:ru-blocked-ips-directblock` - IP's blocked in Russia directly by address.
- `geoip:ru-blocked-ips-noid2971` - IP's and IP ranges blocked in Russia excluding those blocked by 33а-5536/2019.
# GeoSite Categories
- `geosite:category-ru-blocked-domains` - domains and subdomains blocked in Russia.
- `geosite:category-ru-blocked-zones` - only second-level domains blocked in Russia (even if only subdomain was blocked).
# Automatic Update
There is no universal recipe. Just download `geoip.dat` and `geosite.dat` from latest release daily and replace old files with the new ones.
You can find an example of how to get the latest files in the [`update.sh`](./update.sh). And please, for the love of all that is holy, **don't put** `curl -fsSL ... | bash` to your crontab, **it's not safe**.

@ -0,0 +1 @@
Subproject commit f14aa53cc0b67fd5d7eac8b7dc6d7f3d75e8c0c9

1
domain-list-community Submodule

@ -0,0 +1 @@
Subproject commit ea255cb1730b4f29f5a226f234243493fa143cd4

View File

@ -1,28 +0,0 @@
#!/bin/bash
set -euxo pipefail
mkdir -p .temp/result
[ ! -d .temp/az ] && \
git clone --depth=1 https://bitbucket.org/anticensority/antizapret-pac-generator-light.git .temp/az && \
cd .temp/az && \
patch < ../../data/az-cyrillic-idn-fix.patch && \
bash update.sh && \
bash parse.sh && \
cd ../..
[ ! -d .temp/geoip ] && \
git clone --depth=1 https://github.com/v2fly/geoip.git .temp/geoip && \
cat data/geoip-generator-config.json > .temp/geoip/config.json && \
cd .temp/geoip && \
([ ! -f geoip-src.dat ] && curl -fsSL https://github.com/v2fly/geoip/releases/latest/download/geoip.dat -o geoip-src.dat) && \
mkdir -p data && \
cp ../az/result/iplist_all.txt data/ru-blocked-ips-all && \
cp ../az/result/iplist_blockedbyip.txt data/ru-blocked-ips-directblock && \
cp ../az/result/iplist_blockedbyip_noid2971.txt data/ru-blocked-ips-noid2971 && \
go run ./ && \
mv output/dat/geoip.dat ../result/ && \
cd ../..
[ ! -d .temp/geosite ] && \
git clone --depth=1 https://github.com/v2fly/domain-list-community.git .temp/geosite && \
cd .temp/geosite && \
cp ../az/result/hostlist_zones.txt data/category-ru-blocked-zones && \
cp ../az/result/hostlist_original.txt data/category-ru-blocked-domains && \
go run ./ --outputdir=../result --outputname=geosite.dat

1
geoip Submodule

@ -0,0 +1 @@
Subproject commit 3182dda7b38c900f28505b91a44b09ec486e6f36

12
tag.sh
View File

@ -1,12 +0,0 @@
#!/bin/sh
set -eux
export VERSION=`date +%Y%m%d%H%M%S`
curl -X 'POST' \
'https://gitea.neur0tx.site/api/v1/repos/xray-addons/geoip-geosite-with-ru-blocklist/tags?token='"$GITEA_API_KEY"'' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"message": "'"$VERSION"': daily release from ci",
"tag_name": "'"$VERSION"'",
"target": "master"
}'

14
update.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
set -euxo pipefail;
cd "$(dirname "$0")"
current=`curl 'https://gitea.neur0tx.site/api/v1/repos/xray-addons/geoip-geosite-with-ru-blocklist/releases/latest'`
geoipUrl=`echo "$current" | jq -r '.assets | map( { (.name|tostring): . } ) | add | ."geoip.dat".browser_download_url'`
geositeUrl=`echo "$current" | jq -r '.assets | map( { (.name|tostring): . } ) | add | ."geosite.dat".browser_download_url'`
[ -f geoip.dat ] && mv geoip.dat geoip.dat.bak
[ -f geosite.dat ] && mv geosite.dat geosite.dat.bak
curl -fsSL "$geoipUrl" -o geoip.dat
curl -fsSL "$geositeUrl" -o geosite.dat
[ -f geoip.dat ] && [ -f geoip.dat.bak ] && rm geoip.dat.bak
[ -f geosite.dat ] && [ -f geosite.dat.bak ] && rm geosite.dat.bak
[ ! -f geoip.dat ] && mv geoip.dat.bak geoip.dat
[ ! -f geosite.dat ] && mv geosite.dat.bak geosite.dat