diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..d334bd2 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,26 @@ +kind: pipeline +type: docker +name: default + +steps: +- name: generate + image: ubuntu:latest + commands: + - apt install -y idn sipcalc gawk git golang-1.20 + - bash generate.sh +- name: release + image: plugins/gitea-release + settings: + api_key: + from_secret: gitea_api_key + base_url: https://gitea.neur0tx.site + files: .temp/result/* + checksum: + - sha256 + when: + branch: + - master + +trigger: + event: + - push \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b77553d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.temp +.tool-versions diff --git a/README.md b/README.md index 8d6a567..4ed707a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ -# ru-blocklist +# GeoIP & GeoSite with RU blacklist -Generates ru-blocked-dlc.dat and ru-blocked-ips.dat files which can be used in Xray config to route only blocked domains & ips via proxy. \ No newline at end of file +Generates `geoip.dat` and `geosite.dat` for Xray with additional data: +- Category with sites blocked in Russia (`geosite:category-ru-blocked-domains`). +- category with second-level domains of sites blocked in Russia (`geosite:category-ru-blocked-zones`). + +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`. \ No newline at end of file diff --git a/data/az-cyrillic-idn-fix.patch b/data/az-cyrillic-idn-fix.patch new file mode 100644 index 0000000..ec73a72 --- /dev/null +++ b/data/az-cyrillic-idn-fix.patch @@ -0,0 +1,13 @@ +diff --git a/parse.sh b/parse.sh +index c15aba6..c840f3f 100755 +--- a/parse.sh ++++ b/parse.sh +@@ -7,7 +7,7 @@ HERE="$(dirname "$(readlink -f "${0}")")" + cd "$HERE" + + # Extract domains from list +-awk -F ';' '{print $2}' temp/list.csv | sort -u | awk '/^$/ {next} /\\/ {next} /^[а-яА-Яa-zA-Z0-9\-\_\.\*]*+$/ {gsub(/\*\./, ""); gsub(/\.$/, ""); print}' | CHARSET=UTF-8 idn > result/hostlist_original.txt ++awk -F ';' '{print $2}' temp/list.csv | sort -u | awk '/^$/ {next} /\\/ {next} /^[а-яА-Яa-zA-Z0-9\-\_\.\*]*+$/ {gsub(/\*\./, ""); gsub(/\.$/, ""); print}' | grep -Fv 'bеllonа' | CHARSET=UTF-8 idn > result/hostlist_original.txt + + # Generate zones from domains + # FIXME: nxdomain list parsing is disabled due to its instability on z-i diff --git a/data/geoip-generator-config.json b/data/geoip-generator-config.json new file mode 100644 index 0000000..5fbe8af --- /dev/null +++ b/data/geoip-generator-config.json @@ -0,0 +1,32 @@ +{ + "input": [ + { + "type": "v2rayGeoIPDat", + "action": "add", + "args": { + "uri": "./geoip-src.dat" + } + }, + { + "type": "text", + "action": "add", + "args": { + "inputDir": "./data" + } + } + ], + "output": [ + { + "type": "v2rayGeoIPDat", + "action": "output", + "args": { + "outputName": "geoip.dat" + } + }, + { + "type": "text", + "action": "output" + } + ] +} + \ No newline at end of file diff --git a/generate.sh b/generate.sh new file mode 100755 index 0000000..58cc2f9 --- /dev/null +++ b/generate.sh @@ -0,0 +1,28 @@ +#!/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 \ No newline at end of file