From db0fef1cde7e240acba48f48d521a005de36cf3e Mon Sep 17 00:00:00 2001 From: lyc <6648049+tooyoungtoosimp@users.noreply.github.com> Date: Wed, 1 Dec 2021 18:52:04 +0800 Subject: [PATCH] hash --- wg-p2p-client.conf | 4 ++-- wg-p2p-client.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/wg-p2p-client.conf b/wg-p2p-client.conf index 9f460f7..957d22a 100644 --- a/wg-p2p-client.conf +++ b/wg-p2p-client.conf @@ -1,5 +1,5 @@ -url: "http://1.117.146.57:43662" +url: "https://1.117.146.57:43662" local_wg: "wg0" remote_wg: "wg0" peers: - - "bBSgH68LsCaYceSy6xKhFIIU9J+gNsGhKsUPMsUIUCU=" \ No newline at end of file + - "bBSgH68LsCaYceSy6xKhFIIU9J+gNsGhKsUPMsUIUCU=" diff --git a/wg-p2p-client.py b/wg-p2p-client.py index f7430c3..367bcb7 100644 --- a/wg-p2p-client.py +++ b/wg-p2p-client.py @@ -11,7 +11,11 @@ last_local_hash = "" url = f"{cfg['url']}/hash/{cfg['remote_wg']}" urlpat2 = f"{cfg['url']}/peers/{cfg['remote_wg']}" 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( cfg["local_wg"]).encode()).hexdigest() if last_hash != new_hash or last_local_hash != new_local_hash: @@ -24,10 +28,12 @@ while True: res = requests.get( url2, cert=("client1.crt", "client1.key"), - verify=False, + verify="ca.crt", ).json() p["Endpoint"] = res["Endpoint"] 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_local_hash = new_local_hash sleep(5)