add /cluster/statushash endpoint

This commit is contained in:
2023-07-11 18:48:45 +00:00
parent e37969ce3f
commit aa8148fc16
2 changed files with 30 additions and 4 deletions

View File

@@ -1,3 +1,5 @@
import {createHash} from "crypto";
import { getUsedResources, requestPVE } from "./pve.js";
import { db } from "./db.js";
@@ -91,3 +93,10 @@ export async function approveResources (req, username, request) {
});
return approved; // if all requested resources pass, allow
}
export function getObjectHash (object, alg = "sha256", format = "hex") {
const hash = createHash(alg);
hash.update(JSON.stringify(object, Object.keys(object).sort()));
return hash.digest(format);
}