Skip to content

Commit

Permalink
Merge pull request #33 from dmippolitov/ipv6-conversion-fix
Browse files Browse the repository at this point in the history
fixed ipv6 conversion to dnsbl format; added gh actions
  • Loading branch information
dmippolitov authored Oct 17, 2023
2 parents 41a7a5f + 3571957 commit f4ff2e0
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 4 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -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 <package-name> with your PyPI project name
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
2 changes: 1 addition & 1 deletion pydnsbl/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
1 change: 0 additions & 1 deletion pydnsbl/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
7 changes: 7 additions & 0 deletions pydnsbl/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
aiodns>=1.1.1,<=2.0
aiodns>=3,<3.1
idna>=2.9,<3
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit f4ff2e0

Please sign in to comment.