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
This commit is contained in:
BROBIRD
2026-06-02 01:37:00 +08:00
parent 15fbb52452
commit 5af7247d76
2 changed files with 10 additions and 1 deletions

View File

@@ -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

View File

@@ -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