├── .github └── workflows │ ├── Clear Git History.yml │ ├── Delete All Releases.yml │ ├── Delete All Tags.yml │ ├── Delete All Workflows.yml │ ├── Release_ADblock_File.yml │ ├── Run_Adblock_Reject_Domain_TXT.yml │ ├── Run_Adblock_Reject_Generator.yml │ ├── Run_Go_Program_and_Push_Changes.yml │ └── Trigger in sequence.yml ├── LICENSE-CC-BY-NC-SA 4.0 ├── LICENSE-GPL 3.0 ├── README.md ├── Referencing rule sources.txt ├── adblock.dat ├── adblock.txt ├── adblock_reject_domain.txt ├── adblock_rule_generator.ps1 ├── adblock_rule_generator_domain.ps1 ├── main.go └── timestamp.txt /.github/workflows/Clear Git History.yml: -------------------------------------------------------------------------------- 1 | name: Clear Git History 2 | on: 3 | workflow_dispatch: 4 | inputs: 5 | commit_message: 6 | description: 'Commit message for the new initial commit' 7 | required: true 8 | default: 'chore: reset repository history' 9 | 10 | jobs: 11 | clear-history: 12 | runs-on: ubuntu-latest 13 | permissions: 14 | contents: write 15 | steps: 16 | - name: Check out repository 17 | uses: actions/checkout@v4 18 | with: 19 | fetch-depth: 1 20 | 21 | - name: Configure Git 22 | run: | 23 | git config --global user.name 'github-actions[bot]' 24 | git config --global user.email 'github-actions[bot]@users.noreply.github.com' 25 | 26 | - name: Clear history and keep files 27 | run: | 28 | # 保存当前文件的树对象 29 | TREE=$(git write-tree) 30 | 31 | # 创建一个新的提交,使用保存的树对象 32 | NEW_COMMIT=$(echo "${{ github.event.inputs.commit_message }}" | git commit-tree $TREE) 33 | 34 | # 将main分支指向新的提交 35 | git update-ref refs/heads/main $NEW_COMMIT 36 | 37 | # 强制推送 38 | git push -f origin main 39 | 40 | # 清理 41 | git reflog expire --expire=now --all 42 | git gc --prune=now --aggressive 43 | -------------------------------------------------------------------------------- /.github/workflows/Delete All Releases.yml: -------------------------------------------------------------------------------- 1 | name: Delete All Releases 2 | 3 | on: 4 | workflow_dispatch: # 手动触发 5 | schedule: 6 | - cron: '0 */6 * * *' # 每6小时执行一次 7 | 8 | jobs: 9 | delete-releases: 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - name: Checkout repository 14 | uses: actions/checkout@v3 15 | 16 | - name: List and delete all releases (with pagination) 17 | run: | 18 | # 初始化页码和release ID列表 19 | page=1 20 | releases="" 21 | 22 | # 获取所有分页中的release ID 23 | while true; do 24 | result=$(curl -s -H "Authorization: token ${{ secrets.TOKEN }}" \ 25 | "https://api.github.com/repos/${{ github.repository }}/releases?per_page=100&page=$page" | jq -r '.[].id') 26 | 27 | if [ -z "$result" ]; then 28 | break 29 | fi 30 | 31 | releases="$releases $result" 32 | page=$((page + 1)) 33 | done 34 | 35 | # 检查是否有 releases 36 | if [ -z "$releases" ]; then 37 | echo "No releases found." 38 | exit 0 39 | fi 40 | 41 | # 删除每个 release 42 | for id in $releases; do 43 | echo "Deleting release ID: $id" 44 | curl -s -X DELETE -H "Authorization: token ${{ secrets.TOKEN }}" \ 45 | "https://api.github.com/repos/${{ github.repository }}/releases/$id" 46 | done 47 | 48 | echo "All releases deleted." 49 | -------------------------------------------------------------------------------- /.github/workflows/Delete All Tags.yml: -------------------------------------------------------------------------------- 1 | name: Delete All Tags 2 | 3 | on: 4 | workflow_dispatch: # 手动触发 5 | schedule: 6 | - cron: '0 */6 * * *' # 每6小时执行一次 7 | 8 | jobs: 9 | delete-all-tags: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Delete all tags 13 | run: | 14 | # 获取所有标签 15 | tags=$(curl -s -H "Authorization: token ${{ secrets.TOKEN }}" \ 16 | "https://api.github.com/repos/${{ github.repository }}/git/refs/tags" \ 17 | | jq -r '.[].ref' | sed 's|refs/tags/||') 18 | 19 | # 遍历并删除每个标签 20 | for tag in $tags 21 | do 22 | curl -X DELETE -H "Authorization: token ${{ secrets.TOKEN }}" \ 23 | "https://api.github.com/repos/${{ github.repository }}/git/refs/tags/$tag" 24 | echo "Deleted tag: $tag" 25 | done 26 | env: 27 | GITHUB_TOKEN: ${{ secrets.TOKEN }} 28 | -------------------------------------------------------------------------------- /.github/workflows/Delete All Workflows.yml: -------------------------------------------------------------------------------- 1 | name: Delete All Workflows 2 | 3 | on: 4 | schedule: 5 | - cron: '0 0 * * *' # 每天午夜运行 6 | workflow_dispatch: # 允许手动触发 7 | 8 | jobs: 9 | delete-all-workflows: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Delete all workflows 13 | env: 14 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 15 | run: | 16 | # 获取仓库信息 17 | repo_info=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ 18 | "https://api.github.com/repos/${{ github.repository }}") 19 | 20 | # 检查仓库信息是否成功获取 21 | if [ $(echo "$repo_info" | jq -r '.message // empty') = "Not Found" ]; then 22 | echo "Error: Unable to access repository. Please check your permissions." 23 | exit 1 24 | fi 25 | 26 | # 提取所有者和仓库名 27 | OWNER=$(echo "$repo_info" | jq -r '.owner.login') 28 | REPO=$(echo "$repo_info" | jq -r '.name') 29 | 30 | echo "Repository: $OWNER/$REPO" 31 | 32 | # 设置分页参数 33 | per_page=100 34 | page=1 35 | 36 | while true; do 37 | echo "Fetching page $page of all workflow runs..." 38 | 39 | # 获取工作流运行(不再过滤状态) 40 | response=$(curl -s -w "\n%{http_code}" -H "Authorization: token $GITHUB_TOKEN" \ 41 | "https://api.github.com/repos/$OWNER/$REPO/actions/runs?per_page=$per_page&page=$page") 42 | 43 | http_status=$(echo "$response" | tail -n1) 44 | body=$(echo "$response" | sed '$d') 45 | 46 | echo "HTTP Status: $http_status" 47 | echo "Response body:" 48 | echo "$body" 49 | 50 | if [ "$http_status" -ne 200 ]; then 51 | echo "Error: HTTP request failed with status $http_status" 52 | echo "Please ensure that GITHUB_TOKEN has the necessary permissions." 53 | exit 1 54 | fi 55 | 56 | # 检查响应是否为空 57 | if [ -z "$body" ]; then 58 | echo "Error: Empty response received from GitHub API" 59 | exit 1 60 | fi 61 | 62 | # 验证JSON格式 63 | if ! echo "$body" | jq empty; then 64 | echo "Error: Invalid JSON received from GitHub API" 65 | exit 1 66 | fi 67 | 68 | # 提取工作流运行 ID 69 | run_ids=$(echo "$body" | jq -r '.workflow_runs[].id') 70 | 71 | # 如果没有更多的工作流运行,退出循环 72 | if [ -z "$run_ids" ]; then 73 | echo "No more runs found. Exiting loop." 74 | break 75 | fi 76 | 77 | # 删除每个工作流运行 78 | for run_id in $run_ids; do 79 | echo "Deleting workflow run $run_id" 80 | delete_response=$(curl -s -w "\n%{http_code}" -X DELETE -H "Authorization: token $GITHUB_TOKEN" \ 81 | "https://api.github.com/repos/$OWNER/$REPO/actions/runs/$run_id") 82 | 83 | delete_status=$(echo "$delete_response" | tail -n1) 84 | delete_body=$(echo "$delete_response" | sed '$d') 85 | 86 | if [ "$delete_status" -ne 204 ]; then 87 | echo "Warning: Failed to delete run $run_id. Status: $delete_status" 88 | echo "Response: $delete_body" 89 | else 90 | echo "Successfully deleted run $run_id" 91 | fi 92 | done 93 | 94 | # 增加页数以获取下一页结果 95 | page=$((page + 1)) 96 | done 97 | 98 | echo "All workflow runs have been processed." 99 | -------------------------------------------------------------------------------- /.github/workflows/Release_ADblock_File.yml: -------------------------------------------------------------------------------- 1 | name: Release_ADblock_File 2 | 3 | on: 4 | schedule: 5 | - cron: '*/20 * * * *' # 每20分钟运行一次 6 | workflow_dispatch: # 允许手动触发工作流 7 | 8 | jobs: 9 | create-release: 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | # 步骤0:清除之前的日志文件 14 | - name: Clear previous logs 15 | run: | 16 | sudo rm -rf /home/runner/runners/*/_diag/*.log || true 17 | 18 | # 步骤1:检出代码 19 | - name: Checkout code 20 | uses: actions/checkout@v2 21 | 22 | # 步骤2:获取当前时间 23 | - name: Get current time 24 | id: current-time 25 | run: echo "time=$(date +'%y%m%d%H%M')" >> $GITHUB_ENV # 将时间保存为环境变量 26 | 27 | # 步骤3:更新时间戳文件 28 | - name: Update timestamp file 29 | run: echo "${{ env.time }}" > timestamp.txt # 将时间写入 timestamp.txt 文件 30 | 31 | # 步骤4:拉取最新的 main 分支并合并(失败则跳过) 32 | - name: Pull and merge latest main 33 | run: | 34 | git config --global user.name 'github-actions[bot]' 35 | git config --global user.email 'github-actions[bot]@users.noreply.github.com' 36 | git fetch origin main 37 | git merge origin/main --no-edit || echo "Merge failed, skipping merge" 38 | env: 39 | TOKEN: ${{ secrets.TOKEN }} # 使用存储在仓库密钥中的 TOKEN 40 | 41 | # 步骤5:强制添加、提交并推送更改 42 | - name: Force add and commit changes 43 | run: | 44 | git config --global user.name 'github-actions[bot]' 45 | git config --global user.email 'github-actions[bot]@users.noreply.github.com' 46 | git add -f adblock_reject_domain.txt adblock.dat timestamp.txt 47 | git commit -m "Forced update of adblock files and timestamp" || echo "No changes to commit" 48 | git push origin main --force || echo "Push failed, but workflow will continue" 49 | env: 50 | TOKEN: ${{ secrets.TOKEN }} # 使用存储在仓库密钥中的 TOKEN 51 | 52 | # 步骤6:创建新的发布 53 | - name: Get current timestamp 54 | id: get_timestamp 55 | run: echo "time=$(date +%s)" >> $GITHUB_ENV # 获取当前时间的 UNIX 时间戳并存储在 GITHUB_ENV 中 56 | 57 | - name: Create Release 58 | id: create_release 59 | uses: actions/create-release@v1 60 | env: 61 | GITHUB_TOKEN: ${{ secrets.TOKEN }} # 使用 TOKEN 进行身份验证 62 | with: 63 | tag_name: release-${{ env.time }} # 使用时间戳作为标签名 64 | release_name: Release ${{ env.time }} # 使用时间戳作为发布名称 65 | body: "Periodic release of adblock files." # 发布说明 66 | draft: false # 创建正式发布,而非草稿 67 | 68 | # 步骤7:上传 adblock_reject_domain.txt 69 | - name: Upload adblock_reject_domain.txt 70 | uses: actions/upload-release-asset@v1 71 | env: 72 | GITHUB_TOKEN: ${{ secrets.TOKEN }} 73 | with: 74 | upload_url: ${{ steps.create_release.outputs.upload_url }} 75 | asset_path: ./adblock_reject_domain.txt 76 | asset_name: adblock_reject_domain.txt 77 | asset_content_type: text/plain 78 | 79 | # 步骤8:上传 adblock.dat 80 | - name: Upload adblock.dat 81 | uses: actions/upload-release-asset@v1 82 | env: 83 | GITHUB_TOKEN: ${{ secrets.TOKEN }} 84 | with: 85 | upload_url: ${{ steps.create_release.outputs.upload_url }} 86 | asset_path: ./adblock.dat 87 | asset_name: adblock.dat 88 | asset_content_type: application/octet-stream 89 | -------------------------------------------------------------------------------- /.github/workflows/Run_Adblock_Reject_Domain_TXT.yml: -------------------------------------------------------------------------------- 1 | name: Run_Adblock_Reject_Domain_TXT # 工作流名称 2 | 3 | on: 4 | schedule: 5 | - cron: '*/20 * * * *' # 每20分钟运行一次 6 | workflow_dispatch: # 允许手动触发工作流 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest # 使用最新的 Ubuntu 版本作为运行环境 11 | 12 | steps: 13 | - name: Setup Node.js 20 # 设置 Node.js 20 环境 14 | uses: actions/setup-node@v3 # 使用官方的 setup-node 操作来设置 Node.js 环境 15 | with: 16 | node-version: '20' # 指定使用 Node.js 版本 20 17 | 18 | - name: Checkout repository # 检出代码仓库 19 | uses: actions/checkout@v3 # 使用官方的 checkout 操作来检出代码 20 | 21 | - name: Install PowerShell 7 # 安装 PowerShell 7 22 | run: | 23 | sudo apt-get update # 更新包列表 24 | sudo apt-get install -y wget apt-transport-https software-properties-common # 安装必要的包 25 | wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb # 下载微软的包配置文件 26 | sudo dpkg -i packages-microsoft-prod.deb # 安装包配置文件 27 | sudo apt-get update # 更新包列表 28 | sudo apt-get install -y powershell # 安装 PowerShell 7 29 | rm packages-microsoft-prod.deb # 删除包配置文件 30 | 31 | - name: Run adblock_rule_generator_domain.ps1 # 运行 adblock_rule_generator_domain.ps1 脚本 32 | run: pwsh -File ./adblock_rule_generator_domain.ps1 # 使用 PowerShell 7 运行脚本 33 | 34 | - name: Force Add and Commit Domain Txt file # 强制添加并提交 adblock_reject_domain.txt 文件 35 | run: | 36 | git config --global user.name 'github-actions' # 配置提交用户名 37 | git config --global user.email 'github-actions@github.com' # 配置提交邮箱 38 | git add -f adblock_reject_domain.txt # 强制添加 adblock_reject_domain.txt 文件 39 | git commit -m 'Update adblock_reject_domain.txt' || git commit --allow-empty -m 'Empty commit to force push' # 提交更改,若无更改则提交空更改 40 | 41 | - name: Retry Push Domain Txt file # 推送 adblock_reject_domain.txt 文件,失败时重试 42 | env: 43 | TOKEN: ${{ secrets.TOKEN }} # 使用 GitHub 密钥进行身份验证 44 | run: | 45 | for i in {1..5}; do # 尝试最多5次 46 | git push --force origin HEAD && exit 0 || (echo "Push failed, retrying in 10 seconds..." && sleep 10) 47 | done 48 | -------------------------------------------------------------------------------- /.github/workflows/Run_Adblock_Reject_Generator.yml: -------------------------------------------------------------------------------- 1 | name: Run_Adblock_Reject_Generator # 工作流名称 2 | 3 | on: 4 | schedule: 5 | - cron: '*/20 * * * *' # 每20分钟运行一次 6 | workflow_dispatch: # 允许手动触发工作流 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest # 使用最新的 Ubuntu 版本作为运行环境 11 | 12 | steps: 13 | - name: Setup Node.js 20 # 设置 Node.js 20 环境 14 | uses: actions/setup-node@v3 # 使用官方的 setup-node 操作来设置 Node.js 环境 15 | with: 16 | node-version: '20' # 指定使用 Node.js 版本 20 17 | 18 | - name: Checkout repository # 检出代码仓库 19 | uses: actions/checkout@v3 # 使用官方的 checkout 操作 20 | 21 | - name: Install PowerShell 7 # 安装 PowerShell 7 22 | run: | 23 | sudo apt-get update # 更新包列表 24 | sudo apt-get install -y wget apt-transport-https software-properties-common # 安装必要的包 25 | wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb # 下载微软的包配置文件 26 | sudo dpkg -i packages-microsoft-prod.deb # 安装包配置文件 27 | sudo apt-get update # 更新包列表 28 | sudo apt-get install -y powershell # 安装 PowerShell 7 29 | rm packages-microsoft-prod.deb # 删除包配置文件 30 | 31 | - name: Run adblock_rule_generator.ps1 # 运行 adblock_rule_generator.ps1 脚本 32 | run: pwsh -File ./adblock_rule_generator.ps1 # 使用 PowerShell 7 运行脚本 33 | 34 | - name: Force Add and Commit Adblock Txt file # 强制添加并提交 adblock.txt 文件 35 | run: | 36 | git config --global user.name 'github-actions' # 配置提交用户名 37 | git config --global user.email 'github-actions@github.com' # 配置提交邮箱 38 | git add -f adblock.txt # 强制添加 adblock.txt 文件 39 | git commit -m 'Update adblock.txt' || git commit --allow-empty -m 'Empty commit to force push' # 提交更改,若无更改则提交空更改 40 | 41 | - name: Retry Push Adblock Txt file # 推送 adblock.txt 文件,失败时重试 42 | env: 43 | TOKEN: ${{ secrets.TOKEN }} # 使用 GitHub 密钥进行身份验证 44 | run: | 45 | for i in {1..5}; do # 尝试最多5次 46 | git push --force origin HEAD && exit 0 || (echo "Push failed, retrying in 10 seconds..." && sleep 10) 47 | done 48 | -------------------------------------------------------------------------------- /.github/workflows/Run_Go_Program_and_Push_Changes.yml: -------------------------------------------------------------------------------- 1 | name: Run_Go_Program_and_Push_Changes 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | workflow_dispatch: # 手动触发工作流 8 | schedule: 9 | - cron: '*/20 * * * *' # 每20分钟运行一次 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - name: Checkout repository 17 | uses: actions/checkout@v3 18 | 19 | - name: Set up Go 20 | uses: actions/setup-go@v3 21 | with: 22 | go-version: '1.22' # 使用最新的Go 1.22版本 23 | 24 | - name: Create go.mod 25 | run: | 26 | go mod init example.com/myapp || echo "go.mod already exists" 27 | 28 | - name: Add dependencies 29 | run: | 30 | go mod tidy 31 | go mod download 32 | 33 | - name: Run Go program 34 | run: go run main.go 35 | 36 | - name: Configure Git 37 | run: | 38 | git config --global user.name 'github-actions' # 配置提交用户名 39 | git config --global user.email 'github-actions@github.com' # 配置提交邮箱 40 | 41 | - name: Stash changes 42 | run: | 43 | git stash --include-untracked 44 | 45 | - name: Pull remote changes 46 | run: git pull --rebase 47 | 48 | - name: Apply stashed changes 49 | run: git stash pop || echo "No changes to apply" 50 | 51 | - name: Force Add and Commit adblock.dat file # 强制添加并提交 adblock.dat 文件 52 | run: | 53 | git add -f adblock.dat # 强制添加 adblock.dat 文件 54 | git commit -m 'Update adblock.dat' || git commit --allow-empty -m 'Empty commit to force push' # 提交更改,若无更改则提交空更改 55 | 56 | - name: Retry Push adblock.dat file # 推送 adblock.dat 文件,失败时重试 57 | env: 58 | TOKEN: ${{ secrets.TOKEN }} # 使用 GitHub 密钥进行身份验证 59 | run: | 60 | for i in {1..5}; do # 尝试最多5次 61 | git push --force origin HEAD && exit 0 || (echo "Push failed, retrying in 10 seconds..." && sleep 10) 62 | done 63 | -------------------------------------------------------------------------------- /.github/workflows/Trigger in sequence.yml: -------------------------------------------------------------------------------- 1 | name: Trigger in sequence 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | - cron: '*/20 * * * *' # 每20分钟触发一次 7 | 8 | jobs: 9 | trigger_adblock_reject_generator: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Checkout repository 13 | uses: actions/checkout@v3 14 | - name: Trigger and verify Run_Adblock_Reject_Generator 15 | env: 16 | TOKEN: ${{ secrets.TOKEN }} 17 | run: | 18 | workflow_id="Run_Adblock_Reject_Generator.yml" 19 | ref="main" 20 | # 触发工作流 21 | response=$(curl -X POST -H "Authorization: token $TOKEN" \ 22 | -H "Accept: application/vnd.github.v3+json" \ 23 | "https://api.github.com/repos/REIJI007/AdBlock_Rule_For_V2ray/actions/workflows/$workflow_id/dispatches" \ 24 | -d "{\"ref\":\"$ref\"}") 25 | echo "Triggered workflow $workflow_id: $response" 26 | 27 | # 验证工作流成功触发和完成 28 | while : ; do 29 | status=$(curl -s -H "Authorization: token $TOKEN" \ 30 | -H "Accept: application/vnd.github.v3+json" \ 31 | "https://api.github.com/repos/REIJI007/AdBlock_Rule_For_V2ray/actions/runs?workflow_id=$workflow_id&status=completed&branch=$ref" \ 32 | | jq -r '.workflow_runs[0].conclusion') 33 | 34 | if [[ "$status" == "success" ]]; then 35 | echo "Workflow $workflow_id completed successfully." 36 | break 37 | elif [[ "$status" == "failure" ]]; then 38 | echo "Workflow $workflow_id failed." 39 | exit 1 40 | else 41 | echo "Waiting for workflow $workflow_id to complete..." 42 | sleep 30 43 | fi 44 | done 45 | 46 | # 等待90秒后开始下一个工作流 47 | echo "Waiting for 90 seconds before starting the next workflow..." 48 | sleep 90 49 | 50 | trigger_adblock_reject_domain_txt: 51 | needs: trigger_adblock_reject_generator 52 | runs-on: ubuntu-latest 53 | steps: 54 | - name: Checkout repository 55 | uses: actions/checkout@v3 56 | - name: Trigger and verify Run_Adblock_Reject_Domain_TXT 57 | env: 58 | TOKEN: ${{ secrets.TOKEN }} 59 | run: | 60 | workflow_id="Run_Adblock_Reject_Domain_TXT.yml" 61 | ref="main" 62 | # 触发工作流 63 | response=$(curl -X POST -H "Authorization: token $TOKEN" \ 64 | -H "Accept: application/vnd.github.v3+json" \ 65 | "https://api.github.com/repos/REIJI007/AdBlock_Rule_For_V2ray/actions/workflows/$workflow_id/dispatches" \ 66 | -d "{\"ref\":\"$ref\"}") 67 | echo "Triggered workflow $workflow_id: $response" 68 | 69 | # 验证工作流成功触发和完成 70 | while : ; do 71 | status=$(curl -s -H "Authorization: token $TOKEN" \ 72 | -H "Accept: application/vnd.github.v3+json" \ 73 | "https://api.github.com/repos/REIJI007/AdBlock_Rule_For_V2ray/actions/runs?workflow_id=$workflow_id&status=completed&branch=$ref" \ 74 | | jq -r '.workflow_runs[0].conclusion') 75 | 76 | if [[ "$status" == "success" ]]; then 77 | echo "Workflow $workflow_id completed successfully." 78 | break 79 | elif [[ "$status" == "failure" ]]; then 80 | echo "Workflow $workflow_id failed." 81 | exit 1 82 | else 83 | echo "Waiting for workflow $workflow_id to complete..." 84 | sleep 30 85 | fi 86 | done 87 | 88 | # 等待90秒后开始下一个工作流 89 | echo "Waiting for 90 seconds before starting the next workflow..." 90 | sleep 90 91 | 92 | trigger_go_program_and_push_changes: 93 | needs: trigger_adblock_reject_domain_txt 94 | runs-on: ubuntu-latest 95 | steps: 96 | - name: Checkout repository 97 | uses: actions/checkout@v3 98 | - name: Trigger and verify Run_Go_Program_and_Push_Changes 99 | env: 100 | TOKEN: ${{ secrets.TOKEN }} 101 | run: | 102 | workflow_id="Run_Go_Program_and_Push_Changes.yml" 103 | ref="main" 104 | # 触发工作流 105 | response=$(curl -X POST -H "Authorization: token $TOKEN" \ 106 | -H "Accept: application/vnd.github.v3+json" \ 107 | "https://api.github.com/repos/REIJI007/AdBlock_Rule_For_V2ray/actions/workflows/$workflow_id/dispatches" \ 108 | -d "{\"ref\":\"$ref\"}") 109 | echo "Triggered workflow $workflow_id: $response" 110 | 111 | # 验证工作流成功触发和完成 112 | while : ; do 113 | status=$(curl -s -H "Authorization: token $TOKEN" \ 114 | -H "Accept: application/vnd.github.v3+json" \ 115 | "https://api.github.com/repos/REIJI007/AdBlock_Rule_For_V2ray/actions/runs?workflow_id=$workflow_id&status=completed&branch=$ref" \ 116 | | jq -r '.workflow_runs[0].conclusion') 117 | 118 | if [[ "$status" == "success" ]]; then 119 | echo "Workflow $workflow_id completed successfully." 120 | break 121 | elif [[ "$status" == "failure" ]]; then 122 | echo "Workflow $workflow_id failed." 123 | exit 1 124 | else 125 | echo "Waiting for workflow $workflow_id to complete..." 126 | sleep 30 127 | fi 128 | done 129 | 130 | # 等待90秒后开始下一个工作流 131 | echo "Waiting for 90 seconds before starting the next workflow..." 132 | sleep 90 133 | 134 | trigger_release_adblock_file: 135 | needs: trigger_go_program_and_push_changes 136 | runs-on: ubuntu-latest 137 | steps: 138 | - name: Checkout repository 139 | uses: actions/checkout@v3 140 | - name: Trigger and verify Release_ADblock_File 141 | env: 142 | TOKEN: ${{ secrets.TOKEN }} 143 | run: | 144 | workflow_id="Release_ADblock_File.yml" 145 | ref="main" 146 | # 触发工作流 147 | response=$(curl -X POST -H "Authorization: token $TOKEN" \ 148 | -H "Accept: application/vnd.github.v3+json" \ 149 | "https://api.github.com/repos/REIJI007/AdBlock_Rule_For_V2ray/actions/workflows/$workflow_id/dispatches" \ 150 | -d "{\"ref\":\"$ref\"}") 151 | echo "Triggered workflow $workflow_id: $response" 152 | 153 | # 验证工作流成功触发和完成 154 | while : ; do 155 | status=$(curl -s -H "Authorization: token $TOKEN" \ 156 | -H "Accept: application/vnd.github.v3+json" \ 157 | "https://api.github.com/repos/REIJI007/AdBlock_Rule_For_V2ray/actions/runs?workflow_id=$workflow_id&status=completed&branch=$ref" \ 158 | | jq -r '.workflow_runs[0].conclusion') 159 | 160 | if [[ "$status" == "success" ]]; then 161 | echo "Workflow $workflow_id completed successfully." 162 | break 163 | elif [[ "$status" == "failure" ]]; then 164 | echo "Workflow $workflow_id failed." 165 | exit 1 166 | else 167 | echo "Waiting for workflow $workflow_id to complete..." 168 | sleep 30 169 | fi 170 | done 171 | -------------------------------------------------------------------------------- /LICENSE-CC-BY-NC-SA 4.0: -------------------------------------------------------------------------------- 1 | Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) 2 | 3 | You are free to: 4 | Share — copy and redistribute the material in any medium or format 5 | Adapt — remix, transform, and build upon the material 6 | The licensor cannot revoke these freedoms as long as you follow the license terms. 7 | 8 | Under the following terms: 9 | Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. 10 | 11 | NonCommercial — You may not use the material for commercial purposes. 12 | 13 | ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original. 14 | 15 | No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits. 16 | 17 | Notices: 18 | You do not have to comply with the license for elements of the material in the public domain or where your use is permitted by an applicable exception or limitation. 19 | No warranties are given. The license may not give you all of the permissions necessary for your intended use. For example, other rights such as publicity, privacy, or moral rights may limit how you use the material. 20 | -------------------------------------------------------------------------------- /LICENSE-GPL 3.0: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![GPL 3.0 license](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://github.com/REIJI007/AdBlock_Rule_For_V2ray/blob/main/LICENSE-GPL%203.0) 2 | [![CC BY-NC-SA 4.0 license](https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-lightgrey.svg)](https://github.com/REIJI007/AdBlock_Rule_For_V2ray/blob/main/LICENSE-CC-BY-NC-SA%204.0) 3 | 4 |

AdBlock_Rule_For_V2ray

5 | 6 | 7 |

适用于V2ray(V2ray核心与Xray核心)的广告域名拦截adblock.dat二进制文件,每20分钟更新一次

8 | 9 | 10 |

11 | last commit 12 | forks 13 | stars 14 | issues 15 | license 16 |

17 | 18 | **一、从多个广告过滤器中提取拦截域名条目,删除重复项,并将它们转换为兼容V2ray的dat二进制文件,其中列表的每个条目都写成了形如domain:example.com形式,一行仅一条规则。该列表可以用作V2ray的拦截域名路由文件,以阻止广告域名, powershell脚本和main.go转换程序每20分钟自动执行,并将生成的文件发布在release中.两个文件的下载地址分别如下,其中adblock_reject_domain.txt由powershell脚本生成,adblock.dat则是由main.go转换程序将adblock.txt转化得来的dat二进制文件,该文件仅有一个域名标签```ADBLOCK```** 19 |
20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 32 | 33 | 34 | 35 | 39 | 40 |
订阅地址
DAT 29 | Github原始链接 | 30 | Cloudflare加速链接 31 |
拦截域名 36 | Github原始链接 | 37 | Cloudflare加速链接 38 |
41 | 42 | 43 |
44 | 45 | ## 警告:本过滤器订阅有可能破坏某些网站的功能,也有可能封禁某些色情、赌博网站,使用前请斟酌考虑,如有误杀请积极向上游issue反馈,本仓库仅提供去重、筛选、合并功能 46 | 47 |
48 | 49 | **二、可加入此powershell脚本处理的有```adblock plus语法广告过滤器```、```Host拦截列表```、```纯广告域名列表```、```Dnsmasq列表```,请自行酌情添加过滤器订阅URL至powershell脚本中进行处理,你可将该脚本代码复制到本地文本编辑器制作成.ps1后缀的文件运行在powershell上,注意修改生成的文本文件路径,最后在V2ray的json配置中加入被拦截域名,且V2ray配置字段写成类似于如下例子** 50 |
51 |
52 | *简而言之就是可以让你DIY出希望得到的拦截域名列表,缺点是此做法只适合本地定制使用,当然你也可以像本仓库一样部署到GitHub上面,见仁见智* 53 |
54 |
55 | 56 | **三、本仓库引用多个广告过滤器,从这些广告过滤器中提取了被拦截条目的域名,剔除了非拦截项并去重,最后做成adblock.dat二进制文件,虽无法做到面面俱到但能减少广告带来的困扰,请自行斟酌考虑使用。碍于V2ray的路由行为且秉持着尽可能不误杀的原则,本仓库采取域名后缀匹配策略,即匹配命中于拦截列表上的域名或其子域名时触发拦截,除此之外的情况给予放行,尽管这会有许多漏网之鱼的广告被放行** 57 |
58 |
59 | 60 | **四、关于本仓库使用方式:** 61 | 62 | *使用方式一:下载releases中的adblock_reject_domain.txt文件,修改V2ray的json配置中的"routing"字段下的"domain"部分* 63 | 64 |
65 | 66 | 67 | ```conf 68 | 69 | { 70 | "outbounds": 71 | [ 72 | { 73 | "protocol": "blackhole", 74 | "tag": "adblock" // 此outboundTag出站配合下面的域名拦截路由 75 | } 76 | ], 77 | "routing": 78 | { 79 | "domainStrategy": "AsIs", 80 | "rules": 81 | [ 82 | { 83 | "type": "field", 84 | "domain": 85 | [ 86 | "example.com1", // 在这里替换要拦截出站的广告域名,注意最后一个广告条目不用加逗号 87 | "example.com2", 88 | "example.com3" 89 | ], 90 | "outboundTag": "adblock" // 匹配到的域名流量会被导流到名为adblock的outboundTag出站 91 | } 92 | ] 93 | } 94 | } 95 | ``` 96 |
97 | 98 | *使用方式二:下载adblock.dat文件到V2ray同目录下,将下面对应格式的配置文件中"outbounds"字段和"routing"字段内容添加到你的json配置文件中,注意"outbounds"与"routing"之间的配合,注意去掉注释,"tag" 值需要保持一致* 99 |
100 | 101 | 102 | ```conf 103 | { 104 | "outbounds": 105 | [ 106 | { 107 | "protocol": "blackhole", 108 | "tag": "adblock" // 此 outboundTag 出站配合下面的域名拦截路由 109 | } 110 | ], 111 | "routing": 112 | { 113 | "domainStrategy": "AsIs", 114 | "rules": 115 | [ 116 | { 117 | "type": "field", 118 | "domain": 119 | [ 120 | "ext:adblock.dat:adblock" // 引用 adblock.dat 文件中的 adblock 标签 121 | ], 122 | "outboundTag": "adblock" // 匹配到的域名流量会被导流到名为 adblock 的 outboundTag 出站 123 | } 124 | ] 125 | } 126 | } 127 | ``` 128 |
129 | 130 | **五、关于本仓库的使用效果为什么没有普通广告过滤器效果好的疑问解答:** 131 |
132 | *因为普通的广告过滤器包含域名过滤(拦截广告域名)、路径过滤(例如拦截URL路径中包含/ads/的所有请求)、正则表达式过滤(例如拦截所有包含ads.js或ad.js的URL)、类型过滤(例如只拦截图片资源)、隐藏元素等等多因素作用下使得在广告拦截测试网站中可以取得高分。**但碍于V2ray的路由行为(可参考相关文档)**,本仓库仅提取了被拦截域名进行域名匹配过滤,换言之,本仓库就是一个“删减版”的广告过滤器(仅保留了域名匹配过滤功能,规则数在**15万**条左右),所以最终效果没有广告过滤器效果好* 133 |
134 |
135 | 136 | 137 | 138 | **六、本仓库引用的广告过滤规则来源请查看```Referencing rule sources.txt```(目前107个来源)。至于是否误杀域名完全取决于这些处于上游的广告过滤器的域名拦截行为,若不满意的话可按照第二条在本地使用powershell脚本进行DIY本地定制化拦截域名列表,亦或可以像本仓库一样DIY定制后部署到github上面,或者fork本仓库自行DIY** 139 | 140 | 141 | **七、特别鸣谢** 142 | 143 | 144 | 145 | 1. [v2ray](https://github.com/v2fly/v2ray-core) 146 | 2. [Adguard](https://github.com/AdguardTeam/AdGuardFilters) 147 | 148 | 149 | 150 | 151 | 152 | ## LICENSE 153 | - [CC-BY-SA-4.0 License](https://github.com/REIJI007/AdBlock_Rule_For_V2ray/blob/main/LICENSE-CC-BY-NC-SA%204.0) 154 | - [GPL-3.0 License](https://github.com/REIJI007/AdBlock_Rule_For_V2ray/blob/main/LICENSE-GPL%203.0) 155 | -------------------------------------------------------------------------------- /Referencing rule sources.txt: -------------------------------------------------------------------------------- 1 | 引用列表如下: 2 | 3 | 1. ADguard Base filter 4 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_2_Base/filter.txt 5 | 6 | 2. ADguard Spyware filter 7 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_3_Spyware/filter.txt 8 | 9 | 3. ADguard Social filter 10 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_4_Social/filter.txt 11 | 12 | 4. ADguard Mobile filter 13 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_11_Mobile/filter.txt 14 | 15 | 5. ADguard Annoyances filter 16 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_14_Annoyances/filter.txt 17 | 18 | 6. ADguard Dns Filter 19 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_15_DnsFilter/filter.txt 20 | 21 | 7. ADguard TrackParam fliter 22 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_17_TrackParam/filter.txt 23 | 24 | 8. ADguard Annoyances_Cookies filter 25 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_18_Annoyances_Cookies/filter.txt 26 | 27 | 9. ADguard Annoyances_Popups filter 28 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_19_Annoyances_Popups/filter.txt 29 | 30 | 10. ADguard Annoyances_MobileApp filter 31 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_20_Annoyances_MobileApp/filter.txt 32 | 33 | 11. ADguard Annoyances_Other filter 34 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_21_Annoyances_Other/filter.txt 35 | 36 | 12. ADguard Annoyances_Widgets filter 37 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_22_Annoyances_Widgets/filter.txt 38 | 39 | 13. ADguard Chinese filter 40 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_224_Chinese/filter.txt 41 | 42 | 14. ADguard ThirdParty EasyList 43 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_101_EasyList/filter.txt 44 | 45 | 15. ADguard ThirdParty EasyListChina 46 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_104_EasyListChina/filter.txt 47 | 48 | 16. ADguard ThirdParty EasyPrivacy 49 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_118_EasyPrivacy/filter.txt 50 | 51 | 17. ADguard ThirdParty Fanboy's Annoyance List 52 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_122_FanboysAnnoyances/filter.txt 53 | 54 | 18. ADguard ThirdParty FanboysSocialBlockingList 55 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_123_FanboysSocialBlockingList/filter.txt 56 | 57 | 19. ADguard ThirdParty WebAnnoyancesUltralist 58 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_201_WebAnnoyancesUltralist/filter.txt 59 | 60 | 20. ADguard ThirdParty PeterLowesList 61 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_204_PeterLowesList/filter.txt 62 | 63 | 21. ADguard ThirdParty AdblockWarningRemovalList 64 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_207_AdblockWarningRemovalList/filter.txt 65 | 66 | 22. ADguard ThirdParty Online_Malicious_URL_Blocklist 67 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_208_Online_Malicious_URL_Blocklist/filter.txt 68 | 69 | 23. ADguard ThirdParty ADgkMobileChinalist 70 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_209_ADgkMobileChinalist/filter.txt 71 | 72 | 24. ADguard ThirdParty Spam404 73 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_210_Spam404/filter.txt 74 | 75 | 25. ADguard ThirdParty Anti-Adblock Killer 76 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_211_AntiAdblockKillerReek/filter.txt 77 | 78 | 26. ADguard ThirdParty ChinaListAndEasyList 79 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_219_ChinaListAndEasyList/filter.txt 80 | 81 | 27. ADguard ThirdParty CJXsAnnoyanceList 82 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_220_CJXsAnnoyanceList/filter.txt 83 | 84 | 28. ADguard ThirdParty xinggsf 85 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_228_xinggsf/filter.txt 86 | 87 | 29. ADguard ThirdParty IdontCareAboutCookies 88 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_229_IdontCareAboutCookies/filter.txt 89 | 90 | 30. ADguard ThirdParty FanboyAntifonts 91 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_239_FanboyAntifonts/filter.txt 92 | 93 | 31. ADguard ThirdParty BarbBlock 94 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_240_BarbBlock/filter.txt 95 | 96 | 32. ADguard ThirdParty FanboyCookiemonster 97 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_241_FanboyCookiemonster/filter.txt 98 | 99 | 33. ADguard ThirdParty NoCoin 100 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_242_NoCoin/filter.txt 101 | 102 | 34. ADguard ThirdParty DandelionSproutAnnoyances 103 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_250_DandelionSproutAnnoyances/filter.txt 104 | 105 | 35. ADguard ThirdParty Legitimate_URL_Shortener 106 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_251_LegitimateURLShortener/filter.txt 107 | 108 | 36. ADguard ThirdParty Phishing_URL_Blocklist 109 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_255_Phishing_URL_Blocklist/filter.txt 110 | 111 | 37. ADguard ThirdParty Scam_Blocklist 112 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_256_Scam_Blocklist/filter.txt 113 | 114 | 38. ADguard ThirdParty uBlock_Origin_Badware_risks 115 | https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_257_uBlock_Origin_Badware_risks/filter.txt 116 | 117 | 39. ADguard Base filter—first-party servers 118 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/BaseFilter/sections/adservers_firstparty.txt 119 | 120 | 40. ADguard Base filter—foreign servers 121 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/BaseFilter/sections/foreign.txt 122 | 123 | 41. ADguard Base filter cryptominers 124 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/BaseFilter/sections/cryptominers.txt 125 | 126 | 42. ADguard Base filter-adservers 127 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/BaseFilter/sections/adservers.txt 128 | 129 | 43. ADguard Base filter-adservers_firstparty 130 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/BaseFilter/sections/adservers_firstparty.txt 131 | 132 | 44. ADguard Base filter-allowlist 133 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/BaseFilter/sections/allowlist.txt 134 | 135 | 45. ADguard Base filter-allowlist_stealth 136 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/BaseFilter/sections/allowlist_stealth.txt 137 | 138 | 46. ADguard Base filter-antiadblock 139 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/BaseFilter/sections/antiadblock.txt 140 | 141 | 47. ADguard Base filter-replace 142 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/BaseFilter/sections/replace.txt 143 | 144 | 48. ADguard Base filter-content_blocker 145 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/BaseFilter/sections/content_blocker.txt 146 | 147 | 49. ADguard Exclusion rules 148 | https://raw.githubusercontent.com/AdguardTeam/ADguardSDNSFilter/master/Filters/exclusions.txt 149 | 150 | 50. ADguard Exception rules 151 | https://raw.githubusercontent.com/AdguardTeam/ADguardSDNSFilter/master/Filters/exceptions.txt 152 | 153 | 51. ADguard SDNSFilter rules 154 | https://raw.githubusercontent.com/AdguardTeam/ADguardSDNSFilter/master/Filters/rules.txt 155 | 156 | 52. ADguard Tracking Protection filter — first-party trackers 157 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/tracking_servers_firstparty.txt 158 | 159 | 53. ADguard Tracking Protection filter — third-party trackers 160 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/tracking_servers.txt 161 | 162 | 54. ADguard Tracking Protection filter — mobile trackers 163 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/mobile.txt 164 | 165 | 55. ADguard Social filter-allowlist 166 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SocialFilter/sections/allowlist.txt 167 | 168 | 56. ADguard Social filter-general_elemhide 169 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SocialFilter/sections/general_elemhide.txt 170 | 171 | 57. ADguard Social filter-general_extensions 172 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SocialFilter/sections/general_extensions.txt 173 | 174 | 58. ADguard Social filter-general_url 175 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SocialFilter/sections/general_url.txt 176 | 177 | 59. ADguard Social filter-popups 178 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SocialFilter/sections/popups.txt 179 | 180 | 60. ADguard Social filter-social_trackers 181 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SocialFilter/sections/social_trackers.txt 182 | 183 | 61. ADguard Annoyances filter-cookies_allowlist 184 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/Cookies/sections/cookies_allowlist.txt 185 | 186 | 62. ADguard Annoyances filter-cookies_general 187 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/Cookies/sections/cookies_general.txt 188 | 189 | 63. ADguard Annoyances filter-mobile-app_allowlist 190 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/MobileApp/sections/mobile-app_allowlist.txt 191 | 192 | 64. ADguard Annoyances filter-mobile-app_general 193 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/MobileApp/sections/mobile-app_general.txt 194 | 195 | 65. ADguard Annoyances filter-popups-antiadblock 196 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/Popups/sections/antiadblock.txt 197 | 198 | 66. ADguard Annoyances filter-popups-allowlist 199 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/Popups/sections/popups_allowlist.txt 200 | 201 | 67. ADguard Annoyances filter-popups-general 202 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/Popups/sections/popups_general.txt 203 | 204 | 68. ADguard Annoyances filter-popups-push-notifications_allowlist 205 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/Popups/sections/push-notifications_allowlist.txt 206 | 207 | 69. ADguard Annoyances filter-popups-push-notifications_general 208 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/Popups/sections/push-notifications_general.txt 209 | 210 | 70. ADguard Annoyances filter-popups-subscriptions_allowlist 211 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/Popups/sections/subscriptions_allowlist.txt 212 | 213 | 71. ADguard Annoyances filter-popups-subscriptions_general 214 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/Popups/sections/subscriptions_general.txt 215 | 216 | 72. ADguard Annoyances filter-Widgets 217 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/Widgets/sections/widgets.txt 218 | 219 | 73. ADguard CNAME original trackers list 220 | https://raw.githubusercontent.com/AdguardTeam/cname-trackers/master/data/combined_original_trackers.txt 221 | 222 | 74. ADguard CNAME disguised ads list 223 | https://raw.githubusercontent.com/AdguardTeam/cname-trackers/master/data/combined_disguised_ads.txt 224 | 225 | 75. ADguard CNAME disguised clickthroughs list 226 | https://raw.githubusercontent.com/AdguardTeam/cname-trackers/master/data/combined_disguised_clickthroughs.txt 227 | 228 | 76. ADguard CNAME disguised microsites list 229 | https://raw.githubusercontent.com/AdguardTeam/cname-trackers/master/data/combined_disguised_microsites.txt 230 | 231 | 77. ADguard CNAME disguised trackers list 232 | https://raw.githubusercontent.com/AdguardTeam/cname-trackers/master/data/combined_disguised_trackers.txt 233 | 234 | 78. ADguard CNAME disguised mail_trackers list 235 | https://raw.githubusercontent.com/AdguardTeam/cname-trackers/master/data/combined_disguised_mail_trackers.txt 236 | 237 | 79. ADguard Chinese filter-adservers 238 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/ChineseFilter/sections/adservers.txt 239 | 240 | 80. ADguard Chinese filter-adservers_firstparty 241 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/ChineseFilter/sections/adservers_firstparty.txt 242 | 243 | 81. ADguard ChineseFilter-allowlist 244 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/ChineseFilter/sections/allowlist.txt 245 | 246 | 82. ADguard ChineseFilter-antiadblock 247 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/ChineseFilter/sections/antiadblock.txt 248 | 249 | 83. ADguard ChineseFilter-general_elemhide 250 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/ChineseFilter/sections/general_elemhide.txt 251 | 252 | 84. ADguard ChineseFilter-general_extensions 253 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/ChineseFilter/sections/general_extensions.txt 254 | 255 | 85. ADguard ChineseFilter-general_url 256 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/ChineseFilter/sections/general_url.txt 257 | 258 | 86. ADguard ChineseFilter-replace 259 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/ChineseFilter/sections/replace.txt 260 | 261 | 87. ADguard Mobile filter-adservers 262 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/MobileFilter/sections/adservers.txt 263 | 264 | 88. ADguard MobileFilter-allowlist_app 265 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/MobileFilter/sections/allowlist_app.txt 266 | 267 | 89. ADguard MobileFilter-allowlist_web 268 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/MobileFilter/sections/allowlist_web.txt 269 | 270 | 90. ADguard MobileFilter-antiadblock 271 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/MobileFilter/sections/antiadblock.txt 272 | 273 | 91. ADguard MobileFilter-general_elemhide 274 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/MobileFilter/sections/general_elemhide.txt 275 | 276 | 92. ADguard MobileFilter-general_extensions 277 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/MobileFilter/sections/general_extensions.txt 278 | 279 | 93. ADguard MobileFilter-general_url 280 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/MobileFilter/sections/general_url.txt 281 | 282 | 94. ADguard MobileFilter-replace 283 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/MobileFilter/sections/replace.txt 284 | 285 | 95. ADguard SpywareFilter-allowlist 286 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/allowlist.txt 287 | 288 | 96. ADguard SpywareFilter-cookies_allowlist 289 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/cookies_allowlist.txt 290 | 291 | 97. ADguard SpywareFilter-cookies_general 292 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/cookies_general.txt 293 | 294 | 98. ADguard SpywareFilter-cookies_specific 295 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/cookies_specific.txt 296 | 297 | 99. ADguard SpywareFilter-general_elemhide 298 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/general_elemhide.txt 299 | 300 | 100. ADguard SpywareFilter-general_extensions 301 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/general_extensions.txt 302 | 303 | 101. ADguard SpywareFilter-general_url 304 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/general_url.txt 305 | 306 | 102. ADguard SpywareFilter-mobile 307 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/mobile.txt 308 | 309 | 103. ADguard SpywareFilter-mobile_allowlist 310 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/mobile_allowlist.txt 311 | 312 | 104. ADguard SpywareFilter-tracking_servers 313 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/tracking_servers.txt 314 | 315 | 105. ADguard SpywareFilter-tracking_servers_firstparty 316 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/tracking_servers_firstparty.txt 317 | 318 | 106. ADguard TrackParamFilter-allowlist 319 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/TrackParamFilter/sections/allowlist.txt 320 | 321 | 107. ADguard TrackParamFilter-general_url 322 | https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/TrackParamFilter/sections/general_url.txt 323 | -------------------------------------------------------------------------------- /adblock.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/REIJI007/AdBlock_Rule_For_V2ray/b850b2a50f2c1220d2254655ac7b440f2d152f19/adblock.dat -------------------------------------------------------------------------------- /adblock_rule_generator.ps1: -------------------------------------------------------------------------------- 1 | # Title: AdBlock_Rule_For_V2ray 2 | # Description: 适用于V2ray的域名拦截规则集,每20分钟更新一次,确保即时同步上游减少误杀 3 | # Homepage: https://github.com/REIJI007/AdBlock_Rule_For_V2ray 4 | # LICENSE1: https://github.com/REIJI007/AdBlock_Rule_For_V2ray/blob/main/LICENSE-GPL 3.0 5 | # LICENSE2: https://github.com/REIJI007/AdBlock_Rule_For_V2ray/blob/main/LICENSE-CC-BY-NC-SA 4.0 6 | 7 | # 定义广告过滤器URL列表 8 | $urlList = @( 9 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_2_Base/filter.txt", 10 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_3_Spyware/filter.txt", 11 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_4_Social/filter.txt", 12 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_11_Mobile/filter.txt", 13 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_14_Annoyances/filter.txt", 14 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_15_DnsFilter/filter.txt", 15 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_17_TrackParam/filter.txt", 16 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_18_Annoyances_Cookies/filter.txt", 17 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_19_Annoyances_Popups/filter.txt", 18 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_20_Annoyances_MobileApp/filter.txt", 19 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_21_Annoyances_Other/filter.txt", 20 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_22_Annoyances_Widgets/filter.txt", 21 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_224_Chinese/filter.txt", 22 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_101_EasyList/filter.txt", 23 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_104_EasyListChina/filter.txt", 24 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_118_EasyPrivacy/filter.txt", 25 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_122_FanboysAnnoyances/filter.txt", 26 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_123_FanboysSocialBlockingList/filter.txt", 27 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_201_WebAnnoyancesUltralist/filter.txt", 28 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_204_PeterLowesList/filter.txt", 29 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_207_AdblockWarningRemovalList/filter.txt", 30 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_208_Online_Malicious_URL_Blocklist/filter.txt", 31 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_209_ADgkMobileChinalist/filter.txt", 32 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_210_Spam404/filter.txt", 33 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_211_AntiAdblockKillerReek/filter.txt", 34 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_219_ChinaListAndEasyList/filter.txt", 35 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_220_CJXsAnnoyanceList/filter.txt", 36 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_228_xinggsf/filter.txt", 37 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_229_IdontCareAboutCookies/filter.txt", 38 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_239_FanboyAntifonts/filter.txt", 39 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_240_BarbBlock/filter.txt", 40 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_241_FanboyCookiemonster/filter.txt", 41 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_242_NoCoin/filter.txt", 42 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_250_DandelionSproutAnnoyances/filter.txt", 43 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_251_LegitimateURLShortener/filter.txt", 44 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_255_Phishing_URL_Blocklist/filter.txt", 45 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_256_Scam_Blocklist/filter.txt", 46 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_257_uBlock_Origin_Badware_risks/filter.txt", 47 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/BaseFilter/sections/adservers_firstparty.txt", 48 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/BaseFilter/sections/foreign.txt", 49 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/BaseFilter/sections/cryptominers.txt", 50 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/BaseFilter/sections/adservers.txt", 51 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/BaseFilter/sections/adservers_firstparty.txt", 52 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/BaseFilter/sections/allowlist.txt", 53 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/BaseFilter/sections/allowlist_stealth.txt", 54 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/BaseFilter/sections/antiadblock.txt", 55 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/BaseFilter/sections/replace.txt", 56 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/BaseFilter/sections/content_blocker.txt", 57 | "https://raw.githubusercontent.com/AdguardTeam/ADguardSDNSFilter/master/Filters/exclusions.txt", 58 | "https://raw.githubusercontent.com/AdguardTeam/ADguardSDNSFilter/master/Filters/exceptions.txt", 59 | "https://raw.githubusercontent.com/AdguardTeam/ADguardSDNSFilter/master/Filters/rules.txt", 60 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/tracking_servers_firstparty.txt", 61 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/tracking_servers.txt", 62 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/mobile.txt", 63 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SocialFilter/sections/allowlist.txt", 64 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SocialFilter/sections/general_elemhide.txt", 65 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SocialFilter/sections/general_extensions.txt", 66 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SocialFilter/sections/general_url.txt", 67 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SocialFilter/sections/popups.txt", 68 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SocialFilter/sections/social_trackers.txt", 69 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/Cookies/sections/cookies_allowlist.txt", 70 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/Cookies/sections/cookies_general.txt", 71 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/MobileApp/sections/mobile-app_allowlist.txt", 72 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/MobileApp/sections/mobile-app_general.txt", 73 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/Popups/sections/antiadblock.txt", 74 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/Popups/sections/popups_allowlist.txt", 75 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/Popups/sections/popups_general.txt", 76 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/Popups/sections/push-notifications_allowlist.txt", 77 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/Popups/sections/push-notifications_general.txt", 78 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/Popups/sections/subscriptions_allowlist.txt", 79 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/Popups/sections/subscriptions_general.txt", 80 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/Widgets/sections/widgets.txt", 81 | "https://raw.githubusercontent.com/AdguardTeam/cname-trackers/master/data/combined_original_trackers.txt", 82 | "https://raw.githubusercontent.com/AdguardTeam/cname-trackers/master/data/combined_disguised_ads.txt", 83 | "https://raw.githubusercontent.com/AdguardTeam/cname-trackers/master/data/combined_disguised_clickthroughs.txt", 84 | "https://raw.githubusercontent.com/AdguardTeam/cname-trackers/master/data/combined_disguised_microsites.txt", 85 | "https://raw.githubusercontent.com/AdguardTeam/cname-trackers/master/data/combined_disguised_trackers.txt", 86 | "https://raw.githubusercontent.com/AdguardTeam/cname-trackers/master/data/combined_disguised_mail_trackers.txt", 87 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/ChineseFilter/sections/adservers.txt", 88 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/ChineseFilter/sections/adservers_firstparty.txt", 89 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/ChineseFilter/sections/allowlist.txt", 90 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/ChineseFilter/sections/antiadblock.txt", 91 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/ChineseFilter/sections/general_elemhide.txt", 92 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/ChineseFilter/sections/general_extensions.txt", 93 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/ChineseFilter/sections/general_url.txt", 94 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/ChineseFilter/sections/replace.txt", 95 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/MobileFilter/sections/adservers.txt", 96 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/MobileFilter/sections/allowlist_app.txt", 97 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/MobileFilter/sections/allowlist_web.txt", 98 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/MobileFilter/sections/antiadblock.txt", 99 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/MobileFilter/sections/general_elemhide.txt", 100 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/MobileFilter/sections/general_extensions.txt", 101 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/MobileFilter/sections/general_url.txt", 102 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/MobileFilter/sections/replace.txt", 103 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/allowlist.txt", 104 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/cookies_allowlist.txt", 105 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/cookies_general.txt", 106 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/cookies_specific.txt", 107 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/general_elemhide.txt", 108 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/general_extensions.txt", 109 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/general_url.txt", 110 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/mobile.txt", 111 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/mobile_allowlist.txt", 112 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/tracking_servers.txt", 113 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/tracking_servers_firstparty.txt", 114 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/TrackParamFilter/sections/allowlist.txt", 115 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/TrackParamFilter/sections/general_url.txt" 116 | ) 117 | 118 | # 日志文件路径 119 | $logFilePath = "$PSScriptRoot/adblock_log.txt" 120 | 121 | # 创建两个HashSet来存储唯一的规则和排除的域名 122 | $uniqueRules = [System.Collections.Generic.HashSet[string]]::new() 123 | $excludedDomains = [System.Collections.Generic.HashSet[string]]::new() 124 | 125 | # 创建WebClient对象用于下载规则 126 | $webClient = New-Object System.Net.WebClient 127 | $webClient.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36") 128 | 129 | # DNS规范验证函数 130 | function Is-ValidDNSDomain($domain) { 131 | if ($domain.Length -gt 253) { return $false } 132 | $labels = $domain -split "\." 133 | foreach ($label in $labels) { 134 | if ($label.Length -eq 0 -or $label.Length -gt 63) { return $false } 135 | if ($label -notmatch "^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$") { 136 | return $false 137 | } 138 | } 139 | $tld = $labels[-1] 140 | if ($tld -notmatch "^[a-zA-Z]{2,}$") { return $false } 141 | return $true 142 | } 143 | 144 | foreach ($url in $urlList) { 145 | Write-Host "正在处理: $url" 146 | Add-Content -Path $logFilePath -Value "正在处理: $url" 147 | try { 148 | # 读取并拆分内容为行 149 | $content = $webClient.DownloadString($url) 150 | $lines = $content -split "`n" 151 | 152 | foreach ($line in $lines) { 153 | # 直接处理以 @@ 开头的规则,提取域名并加入白名单 154 | if ($line.StartsWith('@@')) { 155 | $domains = $line -replace '^@@', '' -split '[^\w.-]+' 156 | foreach ($domain in $domains) { 157 | if (-not [string]::IsNullOrWhiteSpace($domain) -and $domain -match '[\w-]+(\.[[\w-]+)+') { 158 | $excludedDomains.Add($domain.Trim()) | Out-Null 159 | } 160 | } 161 | } 162 | else { 163 | # 匹配 Adblock/Easylist 格式的规则 164 | if ($line -match '^\|\|([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})\^$') { 165 | $domain = $Matches[1] 166 | $uniqueRules.Add($domain) | Out-Null 167 | } 168 | # 匹配 Hosts 文件格式的 IPv4 规则 169 | elseif ($line -match '^(0\.0\.0\.0|127\.0\.0\.1)\s+([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$') { 170 | $domain = $Matches[2] 171 | $uniqueRules.Add($domain) | Out-Null 172 | } 173 | # 匹配 Hosts 文件格式的 IPv6 规则(以 ::1 或 :: 开头) 174 | elseif ($line -match '^::(1)?\s+([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$') { 175 | $domain = $Matches[2] 176 | $uniqueRules.Add($domain) | Out-Null 177 | } 178 | # 匹配 Dnsmasq address=/域名/格式的规则 179 | elseif ($line -match '^address=/([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})/$') { 180 | $domain = $Matches[1] 181 | $uniqueRules.Add($domain) | Out-Null 182 | } 183 | # 匹配 Dnsmasq server=/域名/的规则 184 | elseif ($line -match '^server=/([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})/$') { 185 | $domain = $Matches[1] 186 | $uniqueRules.Add($domain) | Out-Null 187 | } 188 | # 匹配通配符规则 189 | elseif ($line -match '^\|\|([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})\^$') { 190 | $domain = $Matches[1] 191 | $uniqueRules.Add($domain) | Out-Null 192 | } 193 | # 处理纯域名行 194 | elseif ($line -match '^([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$') { 195 | $domain = $Matches[1] 196 | $uniqueRules.Add($domain) | Out-Null 197 | } 198 | } 199 | } 200 | } 201 | catch { 202 | Write-Host "处理 $url 时出错: $_" 203 | Add-Content -Path $logFilePath -Value "处理 $url 时出错: $_" 204 | } 205 | } 206 | 207 | # 在写入文件之前进行DNS规范验证 208 | $validRules = [System.Collections.Generic.HashSet[string]]::new() 209 | $validExcludedDomains = [System.Collections.Generic.HashSet[string]]::new() 210 | 211 | foreach ($domain in $uniqueRules) { 212 | if (Is-ValidDNSDomain($domain)) { 213 | $validRules.Add($domain) | Out-Null 214 | } 215 | } 216 | 217 | foreach ($domain in $excludedDomains) { 218 | if (Is-ValidDNSDomain($domain)) { 219 | $validExcludedDomains.Add($domain) | Out-Null 220 | } 221 | } 222 | 223 | # 排除所有白名单规则中的域名 224 | $finalRules = $validRules | Where-Object { -not $validExcludedDomains.Contains($_) } 225 | 226 | # 对规则进行排序 227 | $formattedRules = $finalRules | Sort-Object 228 | 229 | # 统计生成的规则条目数量 230 | $ruleCount = $finalRules.Count 231 | 232 | # 获取当前时间并转换为东八区时间 233 | $generationTime = (Get-Date).ToUniversalTime().AddHours(8).ToString("yyyy-MM-dd HH:mm:ss") 234 | 235 | # 创建文本格式的字符串 236 | $textContent = @" 237 | # Title: AdBlock_Rule_For_V2ray 238 | # Description: 适用于V2ray的域名拦截规则集,每20分钟更新一次,确保即时同步上游减少误杀 239 | # Homepage: https://github.com/REIJI007/AdBlock_Rule_For_V2ray 240 | # LICENSE1: https://github.com/REIJI007/AdBlock_Rule_For_V2ray/blob/main/LICENSE-GPL 3.0 241 | # LICENSE2: https://github.com/REIJI007/AdBlock_Rule_For_V2ray/blob/main/LICENSE-CC-BY-NC-SA 4.0 242 | # Generated on: $generationTime 243 | # Generated AdBlock rules 244 | # Total entries: $ruleCount 245 | 246 | $($formattedRules -join "`n") 247 | "@ 248 | 249 | # 定义输出文件路径 250 | $outputPath = "$PSScriptRoot/adblock.txt" 251 | $textContent | Out-File -FilePath $outputPath -Encoding utf8 252 | 253 | # 输出生成的有效规则总数 254 | Write-Host "生成的有效规则总数: $ruleCount" 255 | Add-Content -Path $logFilePath -Value "Total entries: $ruleCount" 256 | -------------------------------------------------------------------------------- /adblock_rule_generator_domain.ps1: -------------------------------------------------------------------------------- 1 | # Title: AdBlock_Rule_For_V2ray 2 | # Description: 适用于V2ray的域名拦截规则集,每20分钟更新一次,确保即时同步上游减少误杀 3 | # Homepage: https://github.com/REIJI007/AdBlock_Rule_For_V2ray 4 | # LICENSE1: https://github.com/REIJI007/AdBlock_Rule_For_V2ray/blob/main/LICENSE-GPL 3.0 5 | # LICENSE2: https://github.com/REIJI007/AdBlock_Rule_For_V2ray/blob/main/LICENSE-CC-BY-NC-SA 4.0 6 | 7 | # 定义广告过滤器URL列表 8 | $urlList = @( 9 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_2_Base/filter.txt", 10 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_3_Spyware/filter.txt", 11 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_4_Social/filter.txt", 12 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_11_Mobile/filter.txt", 13 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_14_Annoyances/filter.txt", 14 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_15_DnsFilter/filter.txt", 15 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_17_TrackParam/filter.txt", 16 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_18_Annoyances_Cookies/filter.txt", 17 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_19_Annoyances_Popups/filter.txt", 18 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_20_Annoyances_MobileApp/filter.txt", 19 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_21_Annoyances_Other/filter.txt", 20 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_22_Annoyances_Widgets/filter.txt", 21 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_224_Chinese/filter.txt", 22 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_101_EasyList/filter.txt", 23 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_104_EasyListChina/filter.txt", 24 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_118_EasyPrivacy/filter.txt", 25 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_122_FanboysAnnoyances/filter.txt", 26 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_123_FanboysSocialBlockingList/filter.txt", 27 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_201_WebAnnoyancesUltralist/filter.txt", 28 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_204_PeterLowesList/filter.txt", 29 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_207_AdblockWarningRemovalList/filter.txt", 30 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_208_Online_Malicious_URL_Blocklist/filter.txt", 31 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_209_ADgkMobileChinalist/filter.txt", 32 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_210_Spam404/filter.txt", 33 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_211_AntiAdblockKillerReek/filter.txt", 34 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_219_ChinaListAndEasyList/filter.txt", 35 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_220_CJXsAnnoyanceList/filter.txt", 36 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_228_xinggsf/filter.txt", 37 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_229_IdontCareAboutCookies/filter.txt", 38 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_239_FanboyAntifonts/filter.txt", 39 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_240_BarbBlock/filter.txt", 40 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_241_FanboyCookiemonster/filter.txt", 41 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_242_NoCoin/filter.txt", 42 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_250_DandelionSproutAnnoyances/filter.txt", 43 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_251_LegitimateURLShortener/filter.txt", 44 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_255_Phishing_URL_Blocklist/filter.txt", 45 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_256_Scam_Blocklist/filter.txt", 46 | "https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/ThirdParty/filter_257_uBlock_Origin_Badware_risks/filter.txt", 47 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/BaseFilter/sections/adservers_firstparty.txt", 48 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/BaseFilter/sections/foreign.txt", 49 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/BaseFilter/sections/cryptominers.txt", 50 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/BaseFilter/sections/adservers.txt", 51 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/BaseFilter/sections/adservers_firstparty.txt", 52 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/BaseFilter/sections/allowlist.txt", 53 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/BaseFilter/sections/allowlist_stealth.txt", 54 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/BaseFilter/sections/antiadblock.txt", 55 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/BaseFilter/sections/replace.txt", 56 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/BaseFilter/sections/content_blocker.txt", 57 | "https://raw.githubusercontent.com/AdguardTeam/ADguardSDNSFilter/master/Filters/exclusions.txt", 58 | "https://raw.githubusercontent.com/AdguardTeam/ADguardSDNSFilter/master/Filters/exceptions.txt", 59 | "https://raw.githubusercontent.com/AdguardTeam/ADguardSDNSFilter/master/Filters/rules.txt", 60 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/tracking_servers_firstparty.txt", 61 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/tracking_servers.txt", 62 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/mobile.txt", 63 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SocialFilter/sections/allowlist.txt", 64 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SocialFilter/sections/general_elemhide.txt", 65 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SocialFilter/sections/general_extensions.txt", 66 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SocialFilter/sections/general_url.txt", 67 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SocialFilter/sections/popups.txt", 68 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SocialFilter/sections/social_trackers.txt", 69 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/Cookies/sections/cookies_allowlist.txt", 70 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/Cookies/sections/cookies_general.txt", 71 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/MobileApp/sections/mobile-app_allowlist.txt", 72 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/MobileApp/sections/mobile-app_general.txt", 73 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/Popups/sections/antiadblock.txt", 74 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/Popups/sections/popups_allowlist.txt", 75 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/Popups/sections/popups_general.txt", 76 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/Popups/sections/push-notifications_allowlist.txt", 77 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/Popups/sections/push-notifications_general.txt", 78 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/Popups/sections/subscriptions_allowlist.txt", 79 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/Popups/sections/subscriptions_general.txt", 80 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/AnnoyancesFilter/Widgets/sections/widgets.txt", 81 | "https://raw.githubusercontent.com/AdguardTeam/cname-trackers/master/data/combined_original_trackers.txt", 82 | "https://raw.githubusercontent.com/AdguardTeam/cname-trackers/master/data/combined_disguised_ads.txt", 83 | "https://raw.githubusercontent.com/AdguardTeam/cname-trackers/master/data/combined_disguised_clickthroughs.txt", 84 | "https://raw.githubusercontent.com/AdguardTeam/cname-trackers/master/data/combined_disguised_microsites.txt", 85 | "https://raw.githubusercontent.com/AdguardTeam/cname-trackers/master/data/combined_disguised_trackers.txt", 86 | "https://raw.githubusercontent.com/AdguardTeam/cname-trackers/master/data/combined_disguised_mail_trackers.txt", 87 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/ChineseFilter/sections/adservers.txt", 88 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/ChineseFilter/sections/adservers_firstparty.txt", 89 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/ChineseFilter/sections/allowlist.txt", 90 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/ChineseFilter/sections/antiadblock.txt", 91 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/ChineseFilter/sections/general_elemhide.txt", 92 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/ChineseFilter/sections/general_extensions.txt", 93 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/ChineseFilter/sections/general_url.txt", 94 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/ChineseFilter/sections/replace.txt", 95 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/MobileFilter/sections/adservers.txt", 96 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/MobileFilter/sections/allowlist_app.txt", 97 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/MobileFilter/sections/allowlist_web.txt", 98 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/MobileFilter/sections/antiadblock.txt", 99 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/MobileFilter/sections/general_elemhide.txt", 100 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/MobileFilter/sections/general_extensions.txt", 101 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/MobileFilter/sections/general_url.txt", 102 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/MobileFilter/sections/replace.txt", 103 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/allowlist.txt", 104 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/cookies_allowlist.txt", 105 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/cookies_general.txt", 106 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/cookies_specific.txt", 107 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/general_elemhide.txt", 108 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/general_extensions.txt", 109 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/general_url.txt", 110 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/mobile.txt", 111 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/mobile_allowlist.txt", 112 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/tracking_servers.txt", 113 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/SpywareFilter/sections/tracking_servers_firstparty.txt", 114 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/TrackParamFilter/sections/allowlist.txt", 115 | "https://raw.githubusercontent.com/AdguardTeam/ADguardFilters/master/TrackParamFilter/sections/general_url.txt" 116 | ) 117 | 118 | # 日志文件路径 119 | $logFilePath = "$PSScriptRoot/adblock_log.txt" 120 | 121 | # 创建两个HashSet来存储唯一的规则和排除的域名 122 | $uniqueRules = [System.Collections.Generic.HashSet[string]]::new() 123 | $excludedDomains = [System.Collections.Generic.HashSet[string]]::new() 124 | 125 | # 创建WebClient对象用于下载规则 126 | $webClient = New-Object System.Net.WebClient 127 | $webClient.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36") 128 | 129 | # DNS规范验证函数 130 | function Is-ValidDNSDomain($domain) { 131 | if ($domain.Length -gt 253) { return $false } 132 | $labels = $domain -split "\." 133 | foreach ($label in $labels) { 134 | if ($label.Length -eq 0 -or $label.Length -gt 63) { return $false } 135 | if ($label -notmatch "^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$") { 136 | return $false 137 | } 138 | } 139 | $tld = $labels[-1] 140 | if ($tld -notmatch "^[a-zA-Z]{2,}$") { return $false } 141 | return $true 142 | } 143 | 144 | foreach ($url in $urlList) { 145 | Write-Host "正在处理: $url" 146 | Add-Content -Path $logFilePath -Value "正在处理: $url" 147 | try { 148 | # 读取并拆分内容为行 149 | $content = $webClient.DownloadString($url) 150 | $lines = $content -split "`n" 151 | 152 | foreach ($line in $lines) { 153 | # 直接处理以 @@ 开头的规则,提取域名并加入白名单 154 | if ($line.StartsWith('@@')) { 155 | $domains = $line -replace '^@@', '' -split '[^\w.-]+' 156 | foreach ($domain in $domains) { 157 | if (-not [string]::IsNullOrWhiteSpace($domain) -and $domain -match '[\w-]+(\.[[\w-]+)+') { 158 | $excludedDomains.Add($domain.Trim()) | Out-Null 159 | } 160 | } 161 | } 162 | else { 163 | # 匹配 Adblock/Easylist 格式的规则 164 | if ($line -match '^\|\|([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})\^$') { 165 | $domain = $Matches[1] 166 | $uniqueRules.Add($domain) | Out-Null 167 | } 168 | # 匹配 Hosts 文件格式的 IPv4 规则 169 | elseif ($line -match '^(0\.0\.0\.0|127\.0\.0\.1)\s+([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$') { 170 | $domain = $Matches[2] 171 | $uniqueRules.Add($domain) | Out-Null 172 | } 173 | # 匹配 Hosts 文件格式的 IPv6 规则(以 ::1 或 :: 开头) 174 | elseif ($line -match '^::(1)?\s+([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$') { 175 | $domain = $Matches[2] 176 | $uniqueRules.Add($domain) | Out-Null 177 | } 178 | # 匹配 Dnsmasq address=/域名/格式的规则 179 | elseif ($line -match '^address=/([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})/$') { 180 | $domain = $Matches[1] 181 | $uniqueRules.Add($domain) | Out-Null 182 | } 183 | # 匹配 Dnsmasq server=/域名/的规则 184 | elseif ($line -match '^server=/([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})/$') { 185 | $domain = $Matches[1] 186 | $uniqueRules.Add($domain) | Out-Null 187 | } 188 | # 匹配通配符规则 189 | elseif ($line -match '^\|\|([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})\^$') { 190 | $domain = $Matches[1] 191 | $uniqueRules.Add($domain) | Out-Null 192 | } 193 | # 处理纯域名行 194 | elseif ($line -match '^([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$') { 195 | $domain = $Matches[1] 196 | $uniqueRules.Add($domain) | Out-Null 197 | } 198 | } 199 | } 200 | } 201 | catch { 202 | Write-Host "处理 $url 时出错: $_" 203 | Add-Content -Path $logFilePath -Value "处理 $url 时出错: $_" 204 | } 205 | } 206 | 207 | # 在写入文件之前进行DNS规范验证 208 | $validRules = [System.Collections.Generic.HashSet[string]]::new() 209 | $validExcludedDomains = [System.Collections.Generic.HashSet[string]]::new() 210 | 211 | foreach ($domain in $uniqueRules) { 212 | if (Is-ValidDNSDomain($domain)) { 213 | $validRules.Add($domain) | Out-Null 214 | } 215 | } 216 | 217 | foreach ($domain in $excludedDomains) { 218 | if (Is-ValidDNSDomain($domain)) { 219 | $validExcludedDomains.Add($domain) | Out-Null 220 | } 221 | } 222 | 223 | # 排除所有白名单规则中的域名 224 | $finalRules = $validRules | Where-Object { -not $validExcludedDomains.Contains($_) } 225 | 226 | # 对规则进行排序并添加前缀和后缀 227 | $formattedRules = $finalRules | Sort-Object | ForEach-Object { 228 | $quote = "`"" 229 | "$quote" + "$_$quote," 230 | } 231 | 232 | # 移除最后一条规则的逗号 233 | if ($formattedRules.Count -gt 0) { 234 | $formattedRules[-1] = $formattedRules[-1].TrimEnd(',') 235 | } 236 | 237 | # 统计生成的规则条目数量 238 | $ruleCount = $finalRules.Count 239 | 240 | # 获取当前东八区时间 241 | $timeZoneInfo = [System.TimeZoneInfo]::FindSystemTimeZoneById("China Standard Time") 242 | $localTime = [System.TimeZoneInfo]::ConvertTime([System.DateTime]::UtcNow, $timeZoneInfo) 243 | $generatedTime = $localTime.ToString("yyyy-MM-dd HH:mm:ss") 244 | 245 | # 创建文本格式的字符串 246 | $textContent = @" 247 | # Title: AdBlock_Rule_For_V2ray 248 | # Description: 适用于V2ray的域名拦截规则集,每20分钟更新一次,确保即时同步上游减少误杀 249 | # Homepage: https://github.com/REIJI007/AdBlock_Rule_For_V2ray 250 | # LICENSE1: https://github.com/REIJI007/AdBlock_Rule_For_V2ray/blob/main/LICENSE-GPL 3.0 251 | # LICENSE2: https://github.com/REIJI007/AdBlock_Rule_For_V2ray/blob/main/LICENSE-CC-BY-NC-SA 4.0 252 | # Generated AdBlock rules 253 | # Generated on: $generatedTime (GMT+8) 254 | # Total entries: $ruleCount 255 | 256 | $($formattedRules -join "`n") 257 | "@ 258 | 259 | # 定义输出文件路径 260 | $outputPath = "$PSScriptRoot/adblock_reject_domain.txt" 261 | $textContent | Out-File -FilePath $outputPath -Encoding utf8 262 | 263 | # 输出生成的有效规则总数 264 | Write-Host "生成的有效规则总数: $ruleCount" 265 | Add-Content -Path $logFilePath -Value "生成的有效规则总数: $ruleCount" 266 | 267 | Pause 268 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bufio" 5 | "errors" 6 | "flag" 7 | "fmt" 8 | "os" 9 | "path/filepath" 10 | "sort" 11 | "strconv" 12 | "strings" 13 | 14 | router "github.com/v2fly/v2ray-core/v5/app/router/routercommon" 15 | "google.golang.org/protobuf/proto" 16 | ) 17 | 18 | // 定义命令行标志 19 | var ( 20 | dataPath = flag.String("datapath", "./", "指定数据文件的目录为仓库根目录") // 修改为仓库根目录 21 | outputName = flag.String("outputname", "adblock.dat", "生成的dat文件的名称") // 修改输出文件名为 adblock.dat 22 | outputDir = flag.String("outputdir", "./", "生成文件的存放目录") 23 | exportLists = flag.String("exportlists", "", "要导出的纯文本格式列表,多个列表用逗号分隔") 24 | ) 25 | 26 | // 定义Entry结构,表示域名条目 27 | type Entry struct { 28 | Type string // 域名类型 (domain, regexp, keyword, full) 29 | Value string // 域名值 30 | Attrs []*router.Domain_Attribute // 域名的附加属性 31 | } 32 | 33 | // 定义List结构,表示包含多个Entry的列表 34 | type List struct { 35 | Name string // 列表名称 36 | Entry []Entry // 列表中的条目 37 | } 38 | 39 | // 定义ParsedList结构,包含解析后的域名条目 40 | type ParsedList struct { 41 | Name string // 列表名称 42 | Inclusion map[string]bool // 已包含的列表 43 | Entry []Entry // 解析后的条目 44 | } 45 | 46 | // 将ParsedList转换为纯文本并写入文件 47 | func (l *ParsedList) toPlainText(listName string) error { 48 | var entryBytes []byte 49 | for _, entry := range l.Entry { 50 | var attrString string 51 | if entry.Attrs != nil { 52 | for _, attr := range entry.Attrs { 53 | attrString += "@" + attr.GetKey() + "," 54 | } 55 | attrString = strings.TrimRight(":"+attrString, ",") 56 | } 57 | // 以 "type:domain.tld:@attr1,@attr2" 的格式保存条目 58 | entryBytes = append(entryBytes, []byte(entry.Type+":"+entry.Value+attrString+"\n")...) 59 | } 60 | if err := os.WriteFile(filepath.Join(*outputDir, listName+".txt"), entryBytes, 0644); err != nil { 61 | return fmt.Errorf(err.Error()) 62 | } 63 | return nil 64 | } 65 | 66 | // 将ParsedList转换为Proto格式 67 | func (l *ParsedList) toProto() (*router.GeoSite, error) { 68 | site := &router.GeoSite{ 69 | CountryCode: l.Name, // 使用列表名称作为国家代码 70 | } 71 | for _, entry := range l.Entry { 72 | switch entry.Type { 73 | case "domain": 74 | site.Domain = append(site.Domain, &router.Domain{ 75 | Type: router.Domain_RootDomain, 76 | Value: entry.Value, 77 | Attribute: entry.Attrs, 78 | }) 79 | case "regexp": 80 | site.Domain = append(site.Domain, &router.Domain{ 81 | Type: router.Domain_Regex, 82 | Value: entry.Value, 83 | Attribute: entry.Attrs, 84 | }) 85 | case "keyword": 86 | site.Domain = append(site.Domain, &router.Domain{ 87 | Type: router.Domain_Plain, 88 | Value: entry.Value, 89 | Attribute: entry.Attrs, 90 | }) 91 | case "full": 92 | site.Domain = append(site.Domain, &router.Domain{ 93 | Type: router.Domain_Full, 94 | Value: entry.Value, 95 | Attribute: entry.Attrs, 96 | }) 97 | default: 98 | return nil, errors.New("未知的域名类型: " + entry.Type) 99 | } 100 | } 101 | return site, nil 102 | } 103 | 104 | // 导出指定列表为纯文本格式 105 | func exportPlainTextList(list []string, refName string, pl *ParsedList) { 106 | for _, listName := range list { 107 | if strings.EqualFold(refName, listName) { 108 | if err := pl.toPlainText(strings.ToLower(refName)); err != nil { 109 | fmt.Println("导出失败: ", err) 110 | continue 111 | } 112 | fmt.Printf("'%s' 已成功生成。\n", listName) 113 | } 114 | } 115 | } 116 | 117 | // 移除行内注释 118 | func removeComment(line string) string { 119 | idx := strings.Index(line, "#") 120 | if idx == -1 { 121 | return line 122 | } 123 | return strings.TrimSpace(line[:idx]) 124 | } 125 | 126 | // 解析域名条目 127 | func parseDomain(domain string, entry *Entry) error { 128 | kv := strings.Split(domain, ":") 129 | if len(kv) == 1 { 130 | entry.Type = "domain" 131 | entry.Value = strings.ToLower(kv[0]) 132 | return nil 133 | } 134 | 135 | if len(kv) == 2 { 136 | entry.Type = strings.ToLower(kv[0]) 137 | entry.Value = strings.ToLower(kv[1]) 138 | return nil 139 | } 140 | 141 | return errors.New("无效的格式: " + domain) 142 | } 143 | 144 | // 解析属性 145 | func parseAttribute(attr string) (*router.Domain_Attribute, error) { 146 | var attribute router.Domain_Attribute 147 | if len(attr) == 0 || attr[0] != '@' { 148 | return &attribute, errors.New("无效的属性: " + attr) 149 | } 150 | 151 | // 去除属性前缀 `@` 152 | attr = attr[1:] 153 | parts := strings.Split(attr, "=") 154 | if len(parts) == 1 { 155 | attribute.Key = strings.ToLower(parts[0]) 156 | attribute.TypedValue = &router.Domain_Attribute_BoolValue{BoolValue: true} 157 | } else { 158 | attribute.Key = strings.ToLower(parts[0]) 159 | intv, err := strconv.Atoi(parts[1]) 160 | if err != nil { 161 | return &attribute, errors.New("无效的属性: " + attr + ": " + err.Error()) 162 | } 163 | attribute.TypedValue = &router.Domain_Attribute_IntValue{IntValue: int64(intv)} 164 | } 165 | return &attribute, nil 166 | } 167 | 168 | // 解析域名条目 169 | func parseEntry(line string) (Entry, error) { 170 | line = strings.TrimSpace(line) 171 | parts := strings.Split(line, " ") 172 | 173 | var entry Entry 174 | if len(parts) == 0 { 175 | return entry, errors.New("空条目") 176 | } 177 | 178 | if err := parseDomain(parts[0], &entry); err != nil { 179 | return entry, err 180 | } 181 | 182 | for i := 1; i < len(parts); i++ { 183 | attr, err := parseAttribute(parts[i]) 184 | if err != nil { 185 | return entry, err 186 | } 187 | entry.Attrs = append(entry.Attrs, attr) 188 | } 189 | 190 | return entry, nil 191 | } 192 | 193 | // 加载指定路径的列表文件 194 | func Load(path string) (*List, error) { 195 | file, err := os.Open(path) 196 | if err != nil { 197 | return nil, err 198 | } 199 | defer file.Close() 200 | 201 | list := &List{ 202 | Name: "ADBLOCK", // 修改列表标签为ADBLOCK 203 | } 204 | scanner := bufio.NewScanner(file) 205 | for scanner.Scan() { 206 | line := strings.TrimSpace(scanner.Text()) 207 | line = removeComment(line) 208 | if len(line) == 0 { 209 | continue 210 | } 211 | entry, err := parseEntry(line) 212 | if err != nil { 213 | return nil, err 214 | } 215 | list.Entry = append(list.Entry, entry) 216 | } 217 | 218 | return list, nil 219 | } 220 | 221 | // 判断条目的属性是否匹配 222 | func isMatchAttr(Attrs []*router.Domain_Attribute, includeKey string) bool { 223 | isMatch := false 224 | mustMatch := true 225 | matchName := includeKey 226 | if strings.HasPrefix(includeKey, "!") { 227 | isMatch = true 228 | mustMatch = false 229 | matchName = strings.TrimLeft(includeKey, "!") 230 | } 231 | 232 | for _, Attr := range Attrs { 233 | attrName := Attr.Key 234 | if mustMatch { 235 | if matchName == attrName { 236 | isMatch = true 237 | break 238 | } 239 | } else { 240 | if matchName == attrName { 241 | isMatch = false 242 | break 243 | } 244 | } 245 | } 246 | return isMatch 247 | } 248 | 249 | // 创建匹配属性的条目列表 250 | func createIncludeAttrEntrys(list *List, matchAttr *router.Domain_Attribute) []Entry { 251 | newEntryList := make([]Entry, 0, len(list.Entry)) 252 | matchName := matchAttr.Key 253 | for _, entry := range list.Entry { 254 | matched := isMatchAttr(entry.Attrs, matchName) 255 | if matched { 256 | newEntryList = append(newEntryList, entry) 257 | } 258 | } 259 | return newEntryList 260 | } 261 | 262 | // 解析列表,并递归处理包含的其他列表 263 | func ParseList(list *List, ref map[string]*List) (*ParsedList, error) { 264 | pl := &ParsedList{ 265 | Name: list.Name, 266 | Inclusion: make(map[string]bool), 267 | } 268 | entryList := list.Entry 269 | for { 270 | newEntryList := make([]Entry, 0, len(entryList)) 271 | hasInclude := false 272 | for _, entry := range entryList { 273 | if entry.Type == "include" { 274 | InclusionName := strings.ToUpper(entry.Value) // 使用InclusionName代替refName 275 | if strings.HasPrefix(InclusionName, "ATTR@") { 276 | attr := &router.Domain_Attribute{ 277 | Key: strings.ToLower(InclusionName[5:]), 278 | } 279 | for _, refList := range ref { 280 | attrEntrys := createIncludeAttrEntrys(refList, attr) 281 | if len(attrEntrys) != 0 { 282 | newEntryList = append(newEntryList, attrEntrys...) 283 | } 284 | } 285 | } else { 286 | if pl.Inclusion[InclusionName] { 287 | continue 288 | } 289 | pl.Inclusion[InclusionName] = true 290 | refList := ref[InclusionName] 291 | if refList == nil { 292 | return nil, errors.New(entry.Value + " 找不到。") 293 | } 294 | newEntryList = append(newEntryList, refList.Entry...) 295 | } 296 | hasInclude = true 297 | } else { 298 | newEntryList = append(newEntryList, entry) 299 | } 300 | } 301 | entryList = newEntryList 302 | if !hasInclude { 303 | break 304 | } 305 | } 306 | pl.Entry = entryList 307 | 308 | return pl, nil 309 | } 310 | 311 | // 主函数 312 | func main() { 313 | flag.Parse() 314 | 315 | // 设定adblock.txt为读取文件 316 | filePath := filepath.Join(".", "adblock.txt") 317 | fmt.Println("使用域名列表文件: ", filePath) 318 | 319 | ref := make(map[string]*List) 320 | list, err := Load(filePath) 321 | if err != nil { 322 | fmt.Println("加载失败: ", err) 323 | os.Exit(1) 324 | } 325 | ref[list.Name] = list 326 | 327 | // 如果输出目录不存在,创建输出目录 328 | if _, err := os.Stat(*outputDir); os.IsNotExist(err) { 329 | if mkErr := os.MkdirAll(*outputDir, 0755); mkErr != nil { 330 | fmt.Println("创建目录失败: ", mkErr) 331 | os.Exit(1) 332 | } 333 | } 334 | 335 | protoList := new(router.GeoSiteList) 336 | pl, err := ParseList(list, ref) 337 | if err != nil { 338 | fmt.Println("解析失败: ", err) 339 | os.Exit(1) 340 | } 341 | site, err := pl.toProto() 342 | if err != nil { 343 | fmt.Println("转换失败: ", err) 344 | os.Exit(1) 345 | } 346 | protoList.Entry = append(protoList.Entry, site) 347 | 348 | // 对protoList进行排序,确保输出的一致性 349 | sort.SliceStable(protoList.Entry, func(i, j int) bool { 350 | return protoList.Entry[i].CountryCode < protoList.Entry[j].CountryCode 351 | }) 352 | 353 | protoBytes, err := proto.Marshal(protoList) 354 | if err != nil { 355 | fmt.Println("生成失败:", err) 356 | os.Exit(1) 357 | } 358 | if err := os.WriteFile(filepath.Join(*outputDir, *outputName), protoBytes, 0644); err != nil { 359 | fmt.Println("写入文件失败: ", err) 360 | os.Exit(1) 361 | } else { 362 | fmt.Println(*outputName, "已成功生成。") 363 | } 364 | } 365 | -------------------------------------------------------------------------------- /timestamp.txt: -------------------------------------------------------------------------------- 1 | 2506021148 2 | --------------------------------------------------------------------------------