Metadata-Version: 2.5
Name: lupaxa-dns-blacklist-checker
Version: 0.1.1
Summary: Check whether an IPv4 address or hostname is listed on DNS blacklists.
Project-URL: Homepage, https://dns-blacklist-checker.thelupaxaproject.org/
Project-URL: Documentation, https://dns-blacklist-checker.thelupaxaproject.org/
Project-URL: Repository, https://github.com/lupaxa-sre-toolbox/dns-blacklist-checker
Project-URL: Issues, https://github.com/lupaxa-sre-toolbox/dns-blacklist-checker/issues
Author: The Lupaxa Project
License: MIT License
        
        Copyright (c) The Lupaxa Project
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENCE
Keywords: blacklist,cli,dns,dnsbl,rbl,sre
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Internet
Classifier: Topic :: System :: Networking
Classifier: Topic :: System :: Systems Administration
Classifier: Topic :: Utilities
Requires-Python: >=3.13
Requires-Dist: dnspython>=2.6
Provides-Extra: dev
Requires-Dist: bump-my-version>=1.2.0; extra == 'dev'
Requires-Dist: hatch>=1.12.0; extra == 'dev'
Requires-Dist: mkdocs-material==9.7.7; extra == 'dev'
Requires-Dist: mkdocs==1.6.1; extra == 'dev'
Requires-Dist: mypy>=1.12.0; extra == 'dev'
Requires-Dist: pip-audit>=2.7.0; extra == 'dev'
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.6.0; extra == 'dev'
Provides-Extra: test
Requires-Dist: pytest-cov>=5.0; extra == 'test'
Requires-Dist: pytest>=8.0; extra == 'test'
Description-Content-Type: text/markdown

<!-- markdownlint-disable -->
<p align="center">
  <a href="https://github.com/lupaxa-sre-toolbox">
    <img src="https://raw.githubusercontent.com/the-lupaxa-project/brand-assets/master/logos/organisations/sre-toolbox/readme-logo.png" alt="Project Logo" width="256"/><br/>
  </a>
</p>
<h3 align="center">
  The Lupaxa SRE Toolbox<br />
  Part of The Lupaxa Project
</h3>

<br />

# lupaxa-dns-blacklist-checker

Check whether an IP address or hostname is listed on DNS blacklists.

## Features

- Query a built-in list of DNSBL zones in parallel
- Accept IPv4 addresses, IPv6 addresses, and hostnames
- Check every address a hostname resolves to
- Check every address of each mail exchanger with `--mx`
- Report the return code and TXT reason for a listing
- Treat Spamhaus and Abusix policy codes as notes, not listings
- Use a Spamhaus Data Query Service key with `--spamhaus-key` or `SPAMHAUS_DQS_KEY`
- Record a zone query failure without treating it as a listing
- Override the zone list and the per-zone timeout
- Install `dns-blacklist-checker`, with `dnsbl` as an alias for the same command
- Use the `check` library API
- Depend only on `dnspython` at runtime

## Installation

### From PyPI

```bash
pip install lupaxa-dns-blacklist-checker
```

### From source (development mode)

```bash
pip install -e ".[dev]"
```

Requires Python 3.13+.

## Library quick start

```python
from lupaxa.dns_blacklist_checker import check

result = check("203.0.113.9", zones=("zen.spamhaus.org", "bl.spamcop.net"))
for item in result.addresses:
    print(item.address, item.listed)
    for zone in item.zones:
        print(zone.zone, zone.detail, zone.return_codes, zone.reason)
```

## CLI quick start

```bash
dns-blacklist-checker --help
dns-blacklist-checker 192.0.2.1 example.com
dns-blacklist-checker 203.0.113.1 --zone zen.spamhaus.org --timeout 5
```

`dnsbl` is an alias for `dns-blacklist-checker`. Both commands accept the same
flags and print the same output.

You can also run the CLI as a module:

```bash
python -m lupaxa.dns_blacklist_checker --help
python -m lupaxa.dns_blacklist_checker --version
```

## Options

- `TARGET`: one or more IPv4 addresses, IPv6 addresses, or hostnames
- `--timeout`, `-t`: per-zone DNS timeout in seconds; default `5`
- `--zone`, `-z`: DNSBL zone to query; repeat to replace the built-in list
- `--mx`: check every address of each mail exchanger for a domain
- `--spamhaus-key`: Spamhaus Data Query Service key; default `SPAMHAUS_DQS_KEY`
- `--version`: print the package version

## Documentation

Online documentation:

[Documentation](https://dns-blacklist-checker.thelupaxaproject.org/)

Source repository:

[GitHub](https://github.com/lupaxa-sre-toolbox/dns-blacklist-checker)

### Serve docs locally

From a clone of the repository:

```bash
make mkdocs-serve
```

Then open the local URL printed by MkDocs in your browser.

## Development

Clone the repository and install with Make:

```bash
make init                # first-time makefile-skills checkout
make python-install-dev  # editable install with [dev]
make python-check        # lint, type-check, and test
```

<a href="https://github.com/the-lupaxa-project">
    <img src="https://raw.githubusercontent.com/the-lupaxa-project/brand-assets/master/logos/components/footer-for-child-orgs.svg" alt="The Lupaxa Project Footer" width="100%" />
</a>
