From 3571957091db91f2d1076504ee1277a99b0605b5 Mon Sep 17 00:00:00 2001 From: Ippolitov Dmitry Date: Tue, 17 Oct 2023 11:00:27 +0300 Subject: [PATCH] fixed ipv6 conversion to dnsbl format; added gh actions --- .github/workflows/pypi.yml | 42 ++++++++++++++++++++++++++++++++++++++ pydnsbl/checker.py | 2 +- pydnsbl/providers.py | 1 - pydnsbl/tests.py | 7 +++++++ requirements.txt | 2 +- setup.py | 2 +- 6 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/pypi.yml diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml new file mode 100644 index 0000000..45a00b8 --- /dev/null +++ b/.github/workflows/pypi.yml @@ -0,0 +1,42 @@ +name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI + +on: push + +jobs: + build: + name: Build distribution 📦 + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + + - name: Install pypa/build + run: >- + python3 -m + pip install + build + --user + - name: Build a binary wheel and a source tarball + run: python3 -m build + - name: Store the distribution packages + uses: actions/upload-artifact@v3 + with: + name: python-package-distributions + path: dist/ + + publish-to-pypi: + name: >- + Publish Python 🐍 distribution 📦 to PyPI + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes + needs: + - build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/pydnsbl # Replace with your PyPI project name + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing \ No newline at end of file diff --git a/pydnsbl/checker.py b/pydnsbl/checker.py index 689b643..aa91cf1 100644 --- a/pydnsbl/checker.py +++ b/pydnsbl/checker.py @@ -164,7 +164,7 @@ def prepare_query(self, request): return '.'.join(reversed(request.split('.'))) elif address.version == 6: # according to RFC: https://tools.ietf.org/html/rfc5782#section-2.4 - request_stripped = request.replace(':', '') + request_stripped = address.exploded.replace(':', '') return '.'.join(reversed([x for x in request_stripped])) else: raise ValueError('unknown ip version') diff --git a/pydnsbl/providers.py b/pydnsbl/providers.py index 8102481..538facb 100644 --- a/pydnsbl/providers.py +++ b/pydnsbl/providers.py @@ -80,7 +80,6 @@ def process_response(self, response): 'dnsbl.cyberlogic.net', 'dnsbl.sorbs.net', 'drone.abuse.ch', - 'dul.ru', 'images.rbl.msrbl.net', 'ips.backscatterer.org', 'ix.dnsbl.manitu.net', diff --git a/pydnsbl/tests.py b/pydnsbl/tests.py index bfdcca9..42cd506 100644 --- a/pydnsbl/tests.py +++ b/pydnsbl/tests.py @@ -99,6 +99,13 @@ def test(): thr.join() assert result.blacklisted +# ipv6 tests +def test_ipv6_converting(): + # https://datatracker.ietf.org/doc/html/rfc5782#section-2.4 + checker = DNSBLIpChecker() + assert checker.prepare_query('2001:db8:1:2:3:4:567:89ab') == "b.a.9.8.7.6.5.0.4.0.0.0.3.0.0.0.2.0.0.0.1.0.0.0.8.b.d.0.1.0.0.2" + + ## COMPAT TESTS def test_checker_compat_0_6(): checker = DNSBLChecker() diff --git a/requirements.txt b/requirements.txt index 8b8df83..7cde5dc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -aiodns>=1.1.1,<=2.0 +aiodns>=3,<3.1 idna>=2.9,<3 \ No newline at end of file diff --git a/setup.py b/setup.py index 7bb395d..dfc681d 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ def get_long_description(): setup( name='pydnsbl', - version='1.1.5', + version='1.1.6', description='Async dnsbl lists checker based on asyncio/aiodns.', long_description=get_long_description(), long_description_content_type='text/markdown',