From 8d27589aa1e96709b9cea89709a0b1f4e34e3b61 Mon Sep 17 00:00:00 2001 From: Sving1024 Date: Sat, 3 May 2025 16:40:58 +0800 Subject: [PATCH] =?UTF-8?q?1.1.4.15=20->=201.1.4.16=20=E7=AC=AC1=E6=AC=A1?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/convert_host_to_toml.py | 24 +++++++++++++ .github/workflows/convert_host_to_toml.yaml | 38 +++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 .github/workflows/convert_host_to_toml.py create mode 100644 .github/workflows/convert_host_to_toml.yaml diff --git a/.github/workflows/convert_host_to_toml.py b/.github/workflows/convert_host_to_toml.py new file mode 100644 index 0000000..e570253 --- /dev/null +++ b/.github/workflows/convert_host_to_toml.py @@ -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") diff --git a/.github/workflows/convert_host_to_toml.yaml b/.github/workflows/convert_host_to_toml.yaml new file mode 100644 index 0000000..44480a0 --- /dev/null +++ b/.github/workflows/convert_host_to_toml.yaml @@ -0,0 +1,38 @@ +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 & Host + uses: actions/checkout@v4 + with: + sparse-checkout: | + .github + Cealing-Host.json + + - 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: | + cp "Cealing-Host.json" ".github/workflows/Cealing-Host.json" + cd ".github/workflows" + python "convert_host_to_toml.py" + + - name: Release Toml + uses: softprops/action-gh-release@v2 + with: + files: Cealing-Host.toml + token: ${{ secrets.GH_TOKEN }}