You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.6 KiB
58 lines
1.6 KiB
# -*- coding: utf-8 -*-
|
|
import os
|
|
import yaml
|
|
|
|
# 读取当前路径
|
|
current_path = os.getcwd()
|
|
|
|
# 新文件夹名称
|
|
new_folder_name = "clash_each_node"
|
|
|
|
# 新文件夹的完整路径
|
|
new_folder_path = os.path.join(current_path, new_folder_name)
|
|
|
|
# 检查文件夹是否存在,如果不存在则创建
|
|
if not os.path.exists(new_folder_path):
|
|
os.makedirs(new_folder_path)
|
|
|
|
config_path = os.path.join(current_path, "merge.yaml")
|
|
|
|
with open(config_path, 'r', encoding='utf-8') as file:
|
|
data = yaml.safe_load(file)
|
|
if not data:
|
|
print(f"Error reading {config_path}")
|
|
exit(1)
|
|
config_name_serial_start = 1
|
|
port_start = 7890
|
|
for proxy in data['proxies']:
|
|
if '剩余流量' in proxy['name']:
|
|
continue
|
|
if '套餐到期' in proxy['name']:
|
|
continue
|
|
config_template = {
|
|
"mixed-port": port_start,
|
|
"allow-lan": True,
|
|
"bind-address": "*",
|
|
"mode": "rule",
|
|
"log-level": "info",
|
|
"external-controller": "0.0.0.0:9090",
|
|
"secret": "",
|
|
"dns": {
|
|
"enable": False,
|
|
"ipv6": False,
|
|
"nameserver": [],
|
|
"fallback": []
|
|
},
|
|
"proxies": [proxy],
|
|
"proxy-groups": [{'name': 'single node', 'type': 'select', 'proxies': [proxy['name']]}],
|
|
}
|
|
|
|
config_name = f"config{str(config_name_serial_start)}.yaml"
|
|
|
|
save_path = os.path.join(new_folder_path, config_name)
|
|
|
|
with open(save_path, 'w', encoding='utf-8') as file:
|
|
yaml.dump(config_template, file, allow_unicode=True, default_flow_style=False)
|
|
|
|
config_name_serial_start += 1
|
|
# port_start += 1
|
|
|