mirror of
https://github.com/ACL4SSR/ACL4SSR.git
synced 2026-06-09 14:02:32 +00:00
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:
3
.github/workflows/update.yml
vendored
3
.github/workflows/update.yml
vendored
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user