1.1.4.15 -> 1.1.4.16 第1次更新

This commit is contained in:
Space Time 2025-05-03 21:25:14 +08:00
parent 57688700ec
commit f785a42d86
4 changed files with 59 additions and 60 deletions

View File

@ -0,0 +1,24 @@
import json
import toml
from collections import defaultdict
def convert_host_to_toml(host_path, toml_path):
with open(host_path) as host_file:
host_rules = json.load(host_file)
toml_rules = defaultdict(dict)
for host_rule in host_rules:
domains, sni, ip = host_rule
for domain in domains:
toml_rules["alter_hostname"][domain] = sni
toml_rules["hosts"][domain] = ip
with open(toml_path, "w") as toml_file:
toml.dump(toml_rules, toml_file)
if __name__ == "__main__":
convert_host_to_toml("Cealing-Host.json", "Cealing-Host.toml")

View File

@ -0,0 +1,35 @@
name: Convert Host To Toml
on:
release:
types: [published]
jobs:
convert_host_to_toml:
name: Convert Host To Toml
runs-on: ubuntu-latest
steps:
- name: Fetch Github Folder
uses: actions/checkout@v4
with:
sparse-checkout: .github
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.x
check-latest: true
- name: Install Toml
run: pip install "toml"
- name: Convert Host To Toml
run: |
cd ".github/workflows"
python "convert_host_to_toml.py"
- name: Release Toml Host
uses: softprops/action-gh-release@v2
with:
files: Cealing-Host.toml
token: ${{ secrets.GH_TOKEN }}

View File

@ -1,23 +0,0 @@
name: Generate toml config and release
on:
push:
tags:
- "*.*.*.*"
jobs:
generate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: generate toml file
run: |
pip install toml
python ./.github/workflows/generate.py
- uses: actions/upload-artifact@v4
with:
name: config
path: |
./*.json
./*.toml
- uses: ncipollo/release-action@v1
with:
artifacts: "./*.json, ./*.toml"

View File

@ -1,37 +0,0 @@
#!/usr/bin/python
import json
import toml
def convert_json_to_toml(json_file_path, toml_file_path):
# 读取JSON文件
with open(json_file_path, "r", encoding="utf-8") as f:
data = json.load(f)
# 初始化TOML数据结构
toml_data = {"alter_hostname": {}, "hosts": {}}
# 处理每个条目
for entry in data:
domains, alter_host, ip = entry
# 处理alter_hostname部分
for domain in domains:
toml_data["alter_hostname"][domain] = alter_host
# 处理hosts部分
for domain in domains:
toml_data["hosts"][domain] = ip
# 写入TOML文件
with open(toml_file_path, "w", encoding="utf-8") as f:
toml.dump(toml_data, f)
# 使用示例
if __name__ == "__main__":
for filename_base in [
"Cealing-Host-R",
"Cealing-Host",
]:
convert_json_to_toml(filename_base + ".json", filename_base + ".toml")