Skip to content

Commit

Permalink
add setup_asn.py
Browse files Browse the repository at this point in the history
  • Loading branch information
harmonsir committed Jan 6, 2025
1 parent 3d93ef0 commit 710dfca
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/scripts/setup_asn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import re

import httpx


http_client = httpx.Client()
pattern = re.compile(r"AS\d+")

r = http_client.get("https://bgp.he.net/country/CN")
as_numbers = re.findall(pattern, r.text)
as_numbers = sorted(map(lambda x: x.upper().strip("AS"), set(as_numbers)))

FILE_PREFIX = "ruleset-"
with open(f"{FILE_PREFIX}ans-cn.conf", "w", encoding="utf8") as wf:
wf.write("\n".join([f"IP-ASN,{as_number}" for as_number in as_numbers]))
1 change: 1 addition & 0 deletions .github/workflows/task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ jobs:
run: |
python .github/scripts/setup_adguard.py
python .github/scripts/setup_v2fly.py
python .github/scripts/setup_asn.py
- name: Git Push
shell: bash
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ DOMAIN-SET,ruleset-easylist-china.conf,REJECT
RULE-SET,ruleset-v2fly-ads.conf,REJECT
RULE-SET,ruleset-v2fly-proxy.conf,PROXY
RULE-SET,ruleset-v2fly-cn.conf,DIRECT
RULE-SET,ruleset-asn-cn.conf,DIRECT
```


Expand Down

0 comments on commit 710dfca

Please sign in to comment.