docker-zerotier-planet/patch/patch.py
Markxu d5cd1505da
修改为Alpine镜像 (#53)
* feat: 🎸 修改部署方式

* feat: 🎸 修改目录

* feat: 🎸 修改文案

* feat: 🎸 修改目录

* feat: 🎸 change mirror

* feat: 🎸 add ignore

* feat: 🎸 增加导出配置的接口

* feat: 🎸 增加导入和导出

* feat: 🎸 mod deploy

* feat: 🎸 del st

* feat: 🎸 使用全局便俩个

* feat: 🎸 增加导入

* 修改ignore

* feat: 🎸 修复打包权限的问题,处理path的我替你

* feat: 🎸 修改文案

* feat: 🎸 名字改下

* feat: 🎸 修改名字

* feat: 🎸 暴漏端口

* feat: 🎸 删除一段代码

* feat: 🎸 use apline

* feat: 🎸 fix path

* feat: 🎸 add json.hpp

* feat: 🎸 mkdir

* feat: 🎸 add mirros

* feat: 🎸 add binding.gyp

* feat: 🎸 update readme

---------

Co-authored-by: xubiaolin <xubiaolin2014@xiaochuankeji.cn>
Co-authored-by: prod <prod@markxu.vip>
2023-02-23 14:06:01 +08:00

52 lines
1.3 KiB
Python

import os
import json
from re import M
def get_moon():
with open("/var/lib/zerotier-one/moon.json", "r") as f:
moon = json.load(f)
return moon
def get_patch():
with open("/app/patch/patch.json", "r") as f:
return json.load(f)
def patch():
moon = get_moon()
patch = get_patch()
identity = moon["roots"][0]["identity"]
moon["roots"][0]["stableEndpoints"] = patch["stableEndpoints"]
# 修改moon
with open("/var/lib/zerotier-one/moon.json", "w") as f:
f.write(json.dumps(moon,sort_keys=True, indent=2))
print("修改后的moon")
print(moon)
# 修改world
moon["roots"][0]["stableEndpoints"] = get_patch()["stableEndpoints"]
text = f"""// Los Angeles
roots.push_back(World::Root());
roots.back().identity = Identity("{identity}");
"""
for i in get_patch()["stableEndpoints"]:
text += f'\n roots.back().stableEndpoints.push_back(InetAddress("{i}"));'
# 生成文件
with open("/app/patch/mkworld.cpp", "r") as cpp:
world = "".join(cpp.readlines())
world = world.replace("//__PATCH_REPLACE__", text)
with open("/app/ZeroTierOne/attic/world/mkworld.cpp", "w") as cpp:
cpp.write(world)
if __name__ == '__main__':
patch()