refactored rule creation

This commit is contained in:
Viet Huynh
2023-09-09 23:12:22 +07:00
parent 603c9a0870
commit 8e96c87c27
3 changed files with 27 additions and 60 deletions
+19
View File
@@ -126,3 +126,22 @@ export const deleteZeroTrustListsAtOnce = async (lists) => {
console.error(`Error occurred while deleting lists - ${err.toString()}`);
}
};
/**
* Creates a Zero Trust rule.
* @param {string} wirefilterExpression The expression to be used for the rule.
* @returns {Promise<any>}
*/
export const createZeroTrustRule = (wirefilterExpression) =>
requestGateway("/rules", {
method: "POST",
body: JSON.stringify({
name: "CGPS Filter Lists",
description:
"Filter lists created by Cloudflare Gateway Pi-hole Scripts. Avoid editing this rule. Changing the name of this rule will break the script.",
enabled: true,
action: "block",
filters: ["dns"],
traffic: wirefilterExpression,
}),
});