Skip to content

Commit 8d27589

Browse files
Sving1024SpaceTimee
authored andcommitted
1.1.4.15 -> 1.1.4.16 第1次更新
1 parent 77b75de commit 8d27589

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import json
2+
import toml
3+
from collections import defaultdict
4+
5+
6+
def convert_host_to_toml(host_path, toml_path):
7+
with open(host_path) as host_file:
8+
host_rules = json.load(host_file)
9+
10+
toml_rules = defaultdict(dict)
11+
12+
for host_rule in host_rules:
13+
domains, sni, ip = host_rule
14+
15+
for domain in domains:
16+
toml_rules["alter_hostname"][domain] = sni
17+
toml_rules["hosts"][domain] = ip
18+
19+
with open(toml_path, "w") as toml_file:
20+
toml.dump(toml_rules, toml_file)
21+
22+
23+
if __name__ == "__main__":
24+
convert_host_to_toml("Cealing-Host.json", "Cealing-Host.toml")
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Convert Host To Toml
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
convert_host_to_toml:
9+
name: Convert Host To Toml
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Fetch Github Folder & Host
13+
uses: actions/checkout@v4
14+
with:
15+
sparse-checkout: |
16+
.github
17+
Cealing-Host.json
18+
19+
- name: Setup Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: 3.x
23+
check-latest: true
24+
25+
- name: Install Toml
26+
run: pip install "toml"
27+
28+
- name: Convert Host To Toml
29+
run: |
30+
cp "Cealing-Host.json" ".github/workflows/Cealing-Host.json"
31+
cd ".github/workflows"
32+
python "convert_host_to_toml.py"
33+
34+
- name: Release Toml
35+
uses: softprops/action-gh-release@v2
36+
with:
37+
files: Cealing-Host.toml
38+
token: ${{ secrets.GH_TOKEN }}

0 commit comments

Comments
 (0)