Using Cloudflare Zero Trust Gateway with WRAP to block ads on your devices.
This script convert adblock list like StevenBlack/hosts or AdAway blocklist to domain list, split it into chunks and upload to Cloudflare Zero Trust Lists, and create a new policy to block those domains using Cloudflare Zero Trust Gateway.
Cloudflare provides a free plan for Zero Trust Gateway, which is enough for this script.
- Cloudflare account with Zero Trust Free plan
- API Token with
Zero Trust:Edit
andAccount Firewall Access Rules:Edit
permissions, which can be created in Cloudflare Dashboard.
- Clone this repository.
- Install dependencies with
pip install -r requirements.txt
. - Set environment variables.
# API Token
export CF_API_TOKEN=your_api_token
# Zone ID of your domain, can be found in url like https://dash.cloudflare.com/{zone_id}
export CF_ZONE_ID=your_zone_id
- Edit
main.py
to set adblock list url.
app = App("Adaway", "https://adaway.org/hosts.txt")
app.run()
- Run
python main.py
.