mirror of
https://github.com/Nezumi-2711/cloudflare-gateway-pihole-scripts.git
synced 2026-09-22 05:31:50 +00:00
improve CI privacy features
This commit is contained in:
@@ -37,7 +37,7 @@ async function getZeroTrustLists() {
|
||||
wirefilter_expression = wirefilter_expression.slice(0, -4);
|
||||
}
|
||||
wirefilter_expression = wirefilter_expression.trim().replace('\n', '');
|
||||
console.log(`Firewall expression contains ${wirefilter_expression.length} characters, and checks against ${filtered_lists.length} filter lists.`)
|
||||
if (!process.env.CI) console.log(`Firewall expression contains ${wirefilter_expression.length} characters, and checks against ${filtered_lists.length} filter lists.`)
|
||||
|
||||
const resp = await axios.request({
|
||||
method: 'POST',
|
||||
|
||||
@@ -28,7 +28,7 @@ async function getZeroTrustRules() {
|
||||
|
||||
if (!filtered_rule) return console.warn("No rule with matching name found - this is not an issue if you haven't run the create script yet. Exiting.");
|
||||
|
||||
console.log(`Deleting rule ` + process.env.CI ? "(redacted, running in CI)" : `${filtered_rule.name} with ID ${filtered_rule.id}`);
|
||||
console.log(`Deleting rule`, process.env.CI ? "(redacted, running in CI)" : `${filtered_rule.name} with ID ${filtered_rule.id}`);
|
||||
|
||||
const resp = await axios.request({
|
||||
method: 'DELETE',
|
||||
|
||||
+4
-4
@@ -7,7 +7,7 @@ const ACCOUNT_ID = process.env.CLOUDFLARE_ACCOUNT_ID;
|
||||
const ACCOUNT_EMAIL = process.env.CLOUDFLARE_ACCOUNT_EMAIL;
|
||||
const LIST_ITEM_LIMIT = Number.isSafeInteger(Number(process.env.CLOUDFLARE_LIST_ITEM_LIMIT)) ? Number(process.env.CLOUDFLARE_LIST_ITEM_LIMIT) : 300000;
|
||||
|
||||
console.log(`List item limit set to ${LIST_ITEM_LIMIT}`);
|
||||
if (!process.env.CI) console.log(`List item limit set to ${LIST_ITEM_LIMIT}`);
|
||||
|
||||
// Read input.csv and parse domains
|
||||
fs.readFile('input.csv', 'utf8', async (err, data) => {
|
||||
@@ -56,7 +56,7 @@ fs.readFile('input.csv', 'utf8', async (err, data) => {
|
||||
|
||||
const listsToCreate = Math.ceil(domains.length / 1000);
|
||||
|
||||
console.log(`Found ${domains.length} valid domains in input.csv after cleanup - ${listsToCreate} list(s) will be created`);
|
||||
if (!process.env.CI) console.log(`Found ${domains.length} valid domains in input.csv after cleanup - ${listsToCreate} list(s) will be created`);
|
||||
|
||||
// Separate domains into chunks of 1000 (Cloudflare list cap)
|
||||
const chunks = chunkArray(domains, 1000);
|
||||
@@ -75,7 +75,7 @@ fs.readFile('input.csv', 'utf8', async (err, data) => {
|
||||
await createZeroTrustList(listName, properList, (index+1), listsToCreate);
|
||||
await sleep(350); // Sleep for 350ms between list additions
|
||||
} catch (error) {
|
||||
console.error(`Error creating list ` + process.env.CI ? "(redacted on CI)" : `"${listName}": ${error.response.data}`);
|
||||
console.error(`Error creating list `, process.env.CI ? "(redacted on CI)" : `"${listName}": ${error.response.data}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -119,7 +119,7 @@ async function createZeroTrustList(name, items, currentItem, totalItems) {
|
||||
);
|
||||
|
||||
const listId = response.data.result.id;
|
||||
console.log(`Created Zero Trust list ` + process.env.CI ? "(redacted on CI)" : `"${name}" with ID ${listId} - ${totalItems - currentItem} left`);
|
||||
console.log(`Created Zero Trust list`, process.env.CI ? "(redacted on CI)" : `"${name}" with ID ${listId} - ${totalItems - currentItem} left`);
|
||||
}
|
||||
|
||||
function percentage(percent, total) {
|
||||
|
||||
+2
-2
@@ -28,10 +28,10 @@ async function getZeroTrustLists() {
|
||||
const cgps_lists = lists.filter(list => list.name.startsWith('CGPS List'));
|
||||
if (!cgps_lists.length) return console.warn("No lists with matching name found - this is not an issue if you haven't created any filter lists before. Exiting.");
|
||||
|
||||
console.log(`Got ${lists.length} lists, ${cgps_lists.length} of which are CGPS lists that will be deleted.`);
|
||||
if (!process.env.CI) console.log(`Got ${lists.length} lists, ${cgps_lists.length} of which are CGPS lists that will be deleted.`);
|
||||
|
||||
for (const list of cgps_lists) {
|
||||
console.log(`Deleting list ` + process.env.CI ? "(redacted, running in CI)" : `${list.name} with ID ${list.id}`);
|
||||
console.log(`Deleting list`, process.env.CI ? "(redacted, running in CI)" : `${list.name} with ID ${list.id}`);
|
||||
const resp = await axios.request({
|
||||
method: 'DELETE',
|
||||
url: `https://api.cloudflare.com/client/v4/accounts/${ACCOUNT_ID}/gateway/lists/${list.id}`,
|
||||
|
||||
Reference in New Issue
Block a user