master
大蒟蒻 4 years ago
parent fa767c765e
commit db0fef1cde

@ -1,5 +1,5 @@
url: "http://1.117.146.57:43662" url: "https://1.117.146.57:43662"
local_wg: "wg0" local_wg: "wg0"
remote_wg: "wg0" remote_wg: "wg0"
peers: peers:
- "bBSgH68LsCaYceSy6xKhFIIU9J+gNsGhKsUPMsUIUCU=" - "bBSgH68LsCaYceSy6xKhFIIU9J+gNsGhKsUPMsUIUCU="

@ -11,7 +11,11 @@ last_local_hash = ""
url = f"{cfg['url']}/hash/{cfg['remote_wg']}" url = f"{cfg['url']}/hash/{cfg['remote_wg']}"
urlpat2 = f"{cfg['url']}/peers/{cfg['remote_wg']}" urlpat2 = f"{cfg['url']}/peers/{cfg['remote_wg']}"
while True: while True:
new_hash = requests.get(url).text new_hash = requests.get(
url,
cert=("client1.crt", "client1.key"),
verify="ca.crt",
).text
new_local_hash = hashlib.sha256(wg_showconf( new_local_hash = hashlib.sha256(wg_showconf(
cfg["local_wg"]).encode()).hexdigest() cfg["local_wg"]).encode()).hexdigest()
if last_hash != new_hash or last_local_hash != new_local_hash: if last_hash != new_hash or last_local_hash != new_local_hash:
@ -24,10 +28,12 @@ while True:
res = requests.get( res = requests.get(
url2, url2,
cert=("client1.crt", "client1.key"), cert=("client1.crt", "client1.key"),
verify=False, verify="ca.crt",
).json() ).json()
p["Endpoint"] = res["Endpoint"] p["Endpoint"] = res["Endpoint"]
wg_syncconf(cfg["local_wg"], str(local_cfg)) wg_syncconf(cfg["local_wg"], str(local_cfg))
new_local_hash = hashlib.sha256(wg_showconf(
cfg["local_wg"]).encode()).hexdigest()
last_hash = new_hash last_hash = new_hash
last_local_hash = new_local_hash last_local_hash = new_local_hash
sleep(5) sleep(5)

Loading…
Cancel
Save