Hanno Böck commited on 2025-06-12 14:03:08
Zeige 3 geänderte Dateien mit 93 Einfügungen und 0 Löschungen.
| ... | ... |
@@ -0,0 +1 @@ |
| 1 |
+DIST courier-pythonfilter-3.0.6.tar.gz 63899 BLAKE2B 8a7e437849abf4f2273c2ae9f117ba30683b74d9dabb6487ce2d0db0868b593da00ae2af2021c3a88ae4155b3d4f63c1b2b0a82bf836244a52a215f9025424e7 SHA512 7d25e6d466351cf987ed71eb9fee8396b87deffbe5a16be17ae94d806a0d9fe8330f243880388d87e7eef3c99fc2a073de94204540c8838995357d5799506ca3 |
| ... | ... |
@@ -0,0 +1,31 @@ |
| 1 |
+# Copyright 1999-2025 Gentoo Authors |
|
| 2 |
+# Distributed under the terms of the GNU General Public License v2 |
|
| 3 |
+ |
|
| 4 |
+EAPI=8 |
|
| 5 |
+PYTHON_COMPAT=( python3_{9,10,11,12,13} )
|
|
| 6 |
+PYPI_NO_NORMALIZE=1 |
|
| 7 |
+DISTUTILS_USE_PEP517=setuptools |
|
| 8 |
+inherit distutils-r1 pypi |
|
| 9 |
+ |
|
| 10 |
+PATCHES=( "${FILESDIR}/${P}-ipv6.diff" )
|
|
| 11 |
+ |
|
| 12 |
+DESCRIPTION="Python filtering architecture for the Courier MTA" |
|
| 13 |
+HOMEPAGE="https://pypi.org/project/courier-pythonfilter/" |
|
| 14 |
+ |
|
| 15 |
+LICENSE="GPL-3" |
|
| 16 |
+SLOT="0" |
|
| 17 |
+KEYWORDS="amd64" |
|
| 18 |
+ |
|
| 19 |
+DEPEND="mail-mta/courier" |
|
| 20 |
+ |
|
| 21 |
+python_install() {
|
|
| 22 |
+ distutils-r1_python_install |
|
| 23 |
+ rm -rf "${D}$(python_get_sitedir)/etc" || die
|
|
| 24 |
+} |
|
| 25 |
+ |
|
| 26 |
+python_install_all() {
|
|
| 27 |
+ distutils-r1_python_install_all |
|
| 28 |
+ |
|
| 29 |
+ insinto /etc |
|
| 30 |
+ doins pythonfilter.conf pythonfilter-modules.conf |
|
| 31 |
+} |
| ... | ... |
@@ -0,0 +1,61 @@ |
| 1 |
+https://github.com/gordonmessmer/courier-pythonfilter/pull/10 |
|
| 2 |
+ |
|
| 3 |
+diff --git a/filters/pythonfilter/whitelist_dnswl.py b/filters/pythonfilter/whitelist_dnswl.py |
|
| 4 |
+index aa03376..57b0ff5 100644 |
|
| 5 |
+--- a/filters/pythonfilter/whitelist_dnswl.py |
|
| 6 |
++++ b/filters/pythonfilter/whitelist_dnswl.py |
|
| 7 |
+@@ -19,6 +19,7 @@ |
|
| 8 |
+ |
|
| 9 |
+ import sys |
|
| 10 |
+ import socket |
|
| 11 |
++import ipaddress |
|
| 12 |
+ import courier.control |
|
| 13 |
+ import courier.config |
|
| 14 |
+ |
|
| 15 |
+@@ -45,22 +46,30 @@ def do_filter(body_path, control_paths): |
|
| 16 |
+ except: |
|
| 17 |
+ return '451 Internal failure locating control files' |
|
| 18 |
+ |
|
| 19 |
+- if senders_ip and '.' in senders_ip: |
|
| 20 |
+- # '.' must be in senders_ip until there are DNSWLs that support IPv6 |
|
| 21 |
+- octets = senders_ip.split('.')
|
|
| 22 |
+- octets.reverse() |
|
| 23 |
+- octets_r = '.'.join(octets) |
|
| 24 |
+- for zone in dnswl_zone: |
|
| 25 |
+- lookup = '%s.%s' % (octets_r, zone) |
|
| 26 |
+- try: |
|
| 27 |
+- lookup_result = socket.gethostbyname(lookup) |
|
| 28 |
+- except: |
|
| 29 |
+- lookup_result = None |
|
| 30 |
+- if lookup_result: |
|
| 31 |
+- # For now, any result is good enough. |
|
| 32 |
+- return '200 Ok' |
|
| 33 |
+- |
|
| 34 |
+- # Return no decision for everyone else. |
|
| 35 |
++ try: |
|
| 36 |
++ sender = ipaddress.ip_address(senders_ip) |
|
| 37 |
++ except ValueError: |
|
| 38 |
++ sys.stderr.write(f'whitelist_dnswl: unparsable senders_ip: {senders_ip}\n')
|
|
| 39 |
++ return '' |
|
| 40 |
++ |
|
| 41 |
++ # sender is either IPV4Address or IPV6Address object, |
|
| 42 |
++ reverse = sender.reverse_pointer.replace('.in-addr.arpa', '').replace('.ip6.arpa', '')
|
|
| 43 |
++ |
|
| 44 |
++ for zone in dnswl_zone: |
|
| 45 |
++ lookup = '%s.%s' % (reverse, zone) |
|
| 46 |
++ try: |
|
| 47 |
++ lookup_result = socket.gethostbyname(lookup) |
|
| 48 |
++ except: |
|
| 49 |
++ lookup_result = None |
|
| 50 |
++ if lookup_result: |
|
| 51 |
++ # special case for access blocked on dnswl.org |
|
| 52 |
++ if lookup_result == '127.0.0.255': |
|
| 53 |
++ # access blocked, no nonspam indicator |
|
| 54 |
++ continue |
|
| 55 |
++ # For now, any other result is good enough. |
|
| 56 |
++ return '200 Ok' |
|
| 57 |
++ |
|
| 58 |
++ # Return no decision if reaching this |
|
| 59 |
+ return '' |
|
| 60 |
+ |
|
| 61 |
+ |
|
| 0 | 62 |