Go to file
dependabot[bot] 235eba5355
Bump urllib3 from 2.0.4 to 2.0.6 (#13)
Bumps [urllib3](https://github.com/urllib3/urllib3) from 2.0.4 to 2.0.6.
- [Release notes](https://github.com/urllib3/urllib3/releases)
- [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst)
- [Commits](https://github.com/urllib3/urllib3/compare/2.0.4...2.0.6)

---
updated-dependencies:
- dependency-name: urllib3
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-16 13:05:04 -05:00
.github/workflows Create python-publish.yml 2023-08-08 16:08:56 -04:00
.vscode Updated README.md 2023-08-06 17:50:44 -04:00
blocklists Added `cmd.py` 2023-07-31 22:39:12 -05:00
src Added flag 2023-08-19 15:05:41 -04:00
.deepsource.toml ci: Add .deepsource.toml 2023-08-06 18:46:02 +00:00
.env.example Use regex for extracting hosts 2023-08-06 17:50:33 -04:00
.gitignore Use regex for extracting hosts 2023-08-06 17:50:33 -04:00
LICENSE Added deletion of DNS Policy 2023-03-26 22:16:26 +00:00
README.md Added badge to README.md 2023-08-08 16:33:41 -04:00
poetry.lock Bump urllib3 from 2.0.4 to 2.0.6 (#13) 2023-10-16 13:05:04 -05:00
pyproject.toml Added flag 2023-08-19 15:05:41 -04:00

README.md

Cloudflare Gateway Adblocking

PyPI
Serverless adblocking via Cloudflare Zero Trust Gateway

What is this?

This is a serverless adblocking solution that uses Cloudflare's Zero Trust Gateway to block ads by parsing a hosts file and creating a firewall rule to block the domains. It can be used as an alternative to Pi-Hole or other adblocking solutions.
This project was heavily inspired by this blog post

Prerequisites

  • Python > 3.10
  • A Cloudflare account with Zero Trust enabled
  • A Cloudflare API tolken with the following permissions:
    • Zero Trust: Edit
    • Account Firewall Access Rules: Edit
    • Access: Apps and Policies: Edit
  • A device with the WARP client installed and configured to use a Zero Trust account

Installation

From PyPi

pip install cloudflare-gateway-adblocking

Usage

Setting Cloudflare credentials

Environment variables

The following environment variables can be used to set the Cloudflare credentials:

  • CLOUDFLARE_ACCOUNT_ID
  • CLOUDFLARE_TOKEN
    These can either be set in the environment or in a .env file in the current working directory.

Command line flags

The following command line flags can be used to set the Cloudflare credentials:

  • Cloudflare Account ID: --account-id / -a
  • Cloudflare Token: --token / -t

Passing blocklists

Blocklists can be passed to the program via the command line flag --blocklist / -b. This flag can either point to a hosts file or a directory containing hosts files. If this flag is not passed, the program will look for a file or directory named blocklists in the current working directory.

Passing whitelists

Whitelists can be passed to the program via the command line flag --whitelist / -w. This flag can either point to a hosts file or a directory containing hosts files. If this flag is not passed, then if a file or directory named whitelists exists in the current working directory, it will be used. Domains in this whitelist will be excluded from the blocklists.

Uploading blocklists and creating a firewall policy

To upload the blocklists to Cloudflare and create a firewall policy, use the upload subcommand.
For example:
cloudflare-gateway-adblocking upload

Deleting blocklists and firewall policy

To delete the blocklists from Cloudflare and delete the firewall policy, use the delete subcommand.
For example:
cloudflare-gateway-adblocking delete

Help

For help, use the --help flag.