Make hash name compatible with Python 3.9
Apparently SHA-256 with a dash works only with Python 3.10.
This commit is contained in:
parent
67bb915e49
commit
5eb0edaaf9
4
app.py
4
app.py
|
@ -43,7 +43,7 @@ def verify_node(d):
|
||||||
if "/" in node:
|
if "/" in node:
|
||||||
raise ValueError("invalid node name %s", node)
|
raise ValueError("invalid node name %s", node)
|
||||||
try:
|
try:
|
||||||
log.info("gettingg client config from %s", "config/" + node)
|
log.info("getting client config from %s", "config/" + node)
|
||||||
with open("config/" + node) as fh:
|
with open("config/" + node) as fh:
|
||||||
node_conf = json.load(fh)
|
node_conf = json.load(fh)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -52,7 +52,7 @@ def verify_node(d):
|
||||||
last = node_conf["last"]
|
last = node_conf["last"]
|
||||||
for key in node_conf["keys"]:
|
for key in node_conf["keys"]:
|
||||||
msg = (node + " " + str(timestamp)).encode("UTF-8")
|
msg = (node + " " + str(timestamp)).encode("UTF-8")
|
||||||
hmac2 = hmac.new(key.encode("UTF-8"), msg, "SHA-256")
|
hmac2 = hmac.new(key.encode("UTF-8"), msg, "SHA256")
|
||||||
digest2 = hmac2.hexdigest()
|
digest2 = hmac2.hexdigest()
|
||||||
if hmac.compare_digest(digest1, digest2):
|
if hmac.compare_digest(digest1, digest2):
|
||||||
if timestamp > node_conf["last"]:
|
if timestamp > node_conf["last"]:
|
||||||
|
|
|
@ -25,7 +25,7 @@ def report_loadavg():
|
||||||
node = hostname
|
node = hostname
|
||||||
timestamp = time.time()
|
timestamp = time.time()
|
||||||
msg = (node + " " + str(timestamp)).encode("UTF-8")
|
msg = (node + " " + str(timestamp)).encode("UTF-8")
|
||||||
digest = hmac.new(client_config["key"].encode("UTF-8"), msg, "SHA-256").hexdigest()
|
digest = hmac.new(client_config["key"].encode("UTF-8"), msg, "SHA256").hexdigest()
|
||||||
report.append(
|
report.append(
|
||||||
{
|
{
|
||||||
"description": {
|
"description": {
|
||||||
|
|
Loading…
Reference in New Issue