Add get_vpn_rule.py
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
def patch_clash_rules():
|
||||
input_file = "clash.yaml"
|
||||
if not os.path.exists(input_file):
|
||||
print(f"Ошибка: Файл {input_file} не найден!")
|
||||
sys.exit(1)
|
||||
|
||||
with open(input_file, "r", encoding="utf-8") as f:
|
||||
content = f.read()
|
||||
|
||||
if "mode: global" in content:
|
||||
content = content.replace("mode: global", "mode: rule")
|
||||
|
||||
if "rules:" in content:
|
||||
base_content = content.split("rules:")[0]
|
||||
else:
|
||||
sys.exit(1)
|
||||
|
||||
advanced_rules = """rules:
|
||||
- DOMAIN-SUFFIX,local,DIRECT
|
||||
- IP-CIDR,127.0.0.0/8,DIRECT
|
||||
- IP-CIDR,172.16.0.0/12,DIRECT
|
||||
- IP-CIDR,192.168.0.0/16,DIRECT
|
||||
- IP-CIDR,10.0.0.0/8,DIRECT
|
||||
- IP-CIDR,198.18.0.0/16,DIRECT
|
||||
- GEOSITE,onion, "→ Remnawave"
|
||||
- GEOSITE,twitter, "→ Remnawave"
|
||||
- GEOSITE,instagram, "→ Remnawave"
|
||||
- GEOSITE,facebook, "→ Remnawave"
|
||||
- GEOSITE,youtube, "→ Remnawave"
|
||||
- GEOSITE,netflix, "→ Remnawave"
|
||||
- GEOSITE,meta, "→ Remnawave"
|
||||
- GEOSITE,geolocation-!cn, "→ Remnawave"
|
||||
- GEOSITE,win-russia,DIRECT
|
||||
- GEOSITE,category-gov-ru,DIRECT
|
||||
- GEOSITE,ru,DIRECT
|
||||
- GEOSITE,yandex,DIRECT
|
||||
- GEOSITE,vk,DIRECT
|
||||
- GEOIP,RU,DIRECT
|
||||
- MATCH,DIRECT
|
||||
"""
|
||||
with open(input_file, "w", encoding="utf-8") as f:
|
||||
f.write(base_content + advanced_rules)
|
||||
|
||||
if __name__ == "__main__":
|
||||
patch_clash_rules()
|
||||
Reference in New Issue
Block a user