cloudflare-gateway-adblocking


Namecloudflare-gateway-adblocking JSON
Version 0.1.3 PyPI version JSON
download
home_pagehttps://github.com/slashtechno/cloudflare-gateway-adblocking
SummaryServerless adblocking via Cloudflare Zero Trust Gateway
upload_time2023-08-19 19:51:34
maintainer
docs_urlNone
authorslastechno
requires_python>=3.10,<4.0
licenseMIT
keywords cloudflare dns adblocking serverless
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Cloudflare Gateway Adblocking  
![PyPI](https://img.shields.io/pypi/v/cloudflare-gateway-adblocking?style=for-the-badge&logo=python&link=https%3A%2F%2Fpypi.org%2Fproject%2Fcloudflare-gateway-adblocking%2F)    
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](https://blog.marcolancini.it/2022/blog-serverless-ad-blocking-with-cloudflare-gateway/)  


### 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.  

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/slashtechno/cloudflare-gateway-adblocking",
    "name": "cloudflare-gateway-adblocking",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "cloudflare,dns,adblocking,serverless",
    "author": "slastechno",
    "author_email": "77907286+slashtechno@users.noreply.github.com",
    "download_url": "https://files.pythonhosted.org/packages/d7/a0/bbf74ba822d35266c6984417a5e79bbfd4d30d3cae06e9afe6d9fffc4ed4/cloudflare_gateway_adblocking-0.1.3.tar.gz",
    "platform": null,
    "description": "# Cloudflare Gateway Adblocking  \n![PyPI](https://img.shields.io/pypi/v/cloudflare-gateway-adblocking?style=for-the-badge&logo=python&link=https%3A%2F%2Fpypi.org%2Fproject%2Fcloudflare-gateway-adblocking%2F)    \nServerless adblocking via Cloudflare Zero Trust Gateway  \n\n### What is this?  \nThis 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.  \nThis project was heavily inspired by [this blog post](https://blog.marcolancini.it/2022/blog-serverless-ad-blocking-with-cloudflare-gateway/)  \n\n\n### Prerequisites\n* Python > 3.10  \n* A Cloudflare account with Zero Trust enabled  \n* A Cloudflare API tolken with the following permissions:  \n    * Zero Trust: Edit  \n    * Account Firewall Access Rules: Edit  \n    * Access: Apps and Policies: Edit  \n* A device with the WARP client installed and configured to use a Zero Trust account  \n\n\n### Installation  \n#### From PyPi  \n`pip install cloudflare-gateway-adblocking`  \n\n\n### Usage   \n#### Setting Cloudflare credentials  \n##### Environment variables  \nThe following environment variables can be used to set the Cloudflare credentials:  \n* `CLOUDFLARE_ACCOUNT_ID`\n* `CLOUDFLARE_TOKEN`  \nThese can either be set in the environment or in a `.env` file in the current working directory.  \n#### Command line flags  \nThe following command line flags can be used to set the Cloudflare credentials:\n* Cloudflare Account ID: `--account-id` / `-a`  \n* Cloudflare Token: `--token` / `-t`  \n#### Passing blocklists  \nBlocklists 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.  \n# Passing whitelists  \nWhitelists 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.  \n#### Uploading blocklists and creating a firewall policy\nTo upload the blocklists to Cloudflare and create a firewall policy, use the `upload` subcommand.  \nFor example:  \n`cloudflare-gateway-adblocking upload`  \n#### Deleting blocklists and firewall policy  \nTo delete the blocklists from Cloudflare and delete the firewall policy, use the `delete` subcommand.  \nFor example:  \n`cloudflare-gateway-adblocking delete`  \n### Help  \nFor help, use the `--help` flag.  \n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Serverless adblocking via Cloudflare Zero Trust Gateway",
    "version": "0.1.3",
    "project_urls": {
        "Homepage": "https://github.com/slashtechno/cloudflare-gateway-adblocking",
        "Repository": "https://github.com/slashtechno/cloudflare-gateway-adblocking"
    },
    "split_keywords": [
        "cloudflare",
        "dns",
        "adblocking",
        "serverless"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a514d7ccf9d528dd1870140bdd954c9c2cac7eb22f56cd90520a6b7206a2ad4e",
                "md5": "87ee6f2133b83b548dbccef5ba762448",
                "sha256": "7a3e50c7e42112386fe9f711256a49cdd4be1cb09d8424da31d61ab160d71cc6"
            },
            "downloads": -1,
            "filename": "cloudflare_gateway_adblocking-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "87ee6f2133b83b548dbccef5ba762448",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 9283,
            "upload_time": "2023-08-19T19:51:32",
            "upload_time_iso_8601": "2023-08-19T19:51:32.052313Z",
            "url": "https://files.pythonhosted.org/packages/a5/14/d7ccf9d528dd1870140bdd954c9c2cac7eb22f56cd90520a6b7206a2ad4e/cloudflare_gateway_adblocking-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d7a0bbf74ba822d35266c6984417a5e79bbfd4d30d3cae06e9afe6d9fffc4ed4",
                "md5": "237b70b1530572f116720f5ed7d738e2",
                "sha256": "28bba26efb5668c0e17980d29fe5af603cb25f4db27c8e4a225e3a0077cf12b6"
            },
            "downloads": -1,
            "filename": "cloudflare_gateway_adblocking-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "237b70b1530572f116720f5ed7d738e2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 7499,
            "upload_time": "2023-08-19T19:51:34",
            "upload_time_iso_8601": "2023-08-19T19:51:34.063035Z",
            "url": "https://files.pythonhosted.org/packages/d7/a0/bbf74ba822d35266c6984417a5e79bbfd4d30d3cae06e9afe6d9fffc4ed4/cloudflare_gateway_adblocking-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-19 19:51:34",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "slashtechno",
    "github_project": "cloudflare-gateway-adblocking",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "cloudflare-gateway-adblocking"
}
        
Elapsed time: 0.10997s