From 5af7247d76910f53997f5fc8b084d81de8d41546 Mon Sep 17 00:00:00 2001 From: BROBIRD <7692707+BROBIRD@users.noreply.github.com> Date: Tue, 2 Jun 2026 01:37:00 +0800 Subject: [PATCH] ci(github actions): restrict scheduled workflow to master branch, improve ipv6 cidr check 1. add master branch restriction for update workflow, only allow manual trigger on master 2. rewrite ipv6 cidr validation with proper regex patterns, include ipv4-mapped ipv6 check --- .github/workflows/update.yml | 3 +++ scripts/gfwlist_parser.py | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index b72ddce..c1393e2 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -4,10 +4,13 @@ on: schedule: - cron: '0 0 * * *' workflow_dispatch: + branches: + - master jobs: update: runs-on: ubuntu-slim + if: github.ref == 'refs/heads/master' steps: - name: Checkout repository uses: actions/checkout@v4 diff --git a/scripts/gfwlist_parser.py b/scripts/gfwlist_parser.py index 5133269..44219a9 100644 --- a/scripts/gfwlist_parser.py +++ b/scripts/gfwlist_parser.py @@ -43,9 +43,15 @@ def is_cidr(s): return True return False if ':' in ip_part: - if all(c in set('0123456789abcdefABCDEF:') for c in ip_part): + ipv6_pattern = r'^([0-9a-fA-F]{0,4}:){1,7}[0-9a-fA-F]{0,4}$|^(::)$|^::1$' + if re.match(ipv6_pattern, ip_part): if 0 <= suffix_val <= 128: return True + if ip_part.startswith('::ffff:'): + ipv4_in_v6_pattern = r'^::ffff:(\d{1,3}\.){3}\d{1,3}$' + if re.match(ipv4_in_v6_pattern, ip_part): + if 0 <= suffix_val <= 128: + return True return False return False