...
 
Commits (9)
postfix-mta-sts-resolver
========================
[![Build Status](https://travis-ci.org/Snawoot/postfix-mta-sts-resolver.svg?branch=master)](https://travis-ci.org/Snawoot/postfix-mta-sts-resolver) [![Coverage](https://img.shields.io/badge/coverage-100%25-4dc71f.svg)](https://travis-ci.org/Snawoot/postfix-mta-sts-resolver) [![PyPI - Downloads](https://img.shields.io/pypi/dm/postfix-mta-sts-resolver.svg?color=4dc71f&label=PyPI%20downloads)](https://pypistats.org/packages/postfix-mta-sts-resolver) [![PyPI](https://img.shields.io/pypi/v/postfix-mta-sts-resolver.svg)](https://pypi.org/project/postfix-mta-sts-resolver/) [![PyPI - Status](https://img.shields.io/pypi/status/postfix-mta-sts-resolver.svg)](https://pypi.org/project/postfix-mta-sts-resolver/) [![PyPI - License](https://img.shields.io/pypi/l/postfix-mta-sts-resolver.svg?color=4dc71f)](https://pypi.org/project/postfix-mta-sts-resolver/)
[![Build Status](https://travis-ci.org/Snawoot/postfix-mta-sts-resolver.svg?branch=master)](https://travis-ci.org/Snawoot/postfix-mta-sts-resolver) [![Coverage](https://img.shields.io/badge/coverage-97%25-4dc71f.svg)](https://travis-ci.org/Snawoot/postfix-mta-sts-resolver) [![PyPI - Downloads](https://img.shields.io/pypi/dm/postfix-mta-sts-resolver.svg?color=4dc71f&label=PyPI%20downloads)](https://pypistats.org/packages/postfix-mta-sts-resolver) [![PyPI](https://img.shields.io/pypi/v/postfix-mta-sts-resolver.svg)](https://pypi.org/project/postfix-mta-sts-resolver/) [![PyPI - Status](https://img.shields.io/pypi/status/postfix-mta-sts-resolver.svg)](https://pypi.org/project/postfix-mta-sts-resolver/) [![PyPI - License](https://img.shields.io/pypi/l/postfix-mta-sts-resolver.svg?color=4dc71f)](https://pypi.org/project/postfix-mta-sts-resolver/)
Daemon which provides TLS client policy for Postfix via socketmap, according to domain MTA-STS policy. Current support of RFC8461 is limited - daemon lacks some minor features:
......
......@@ -5,9 +5,6 @@ import asyncio
MAX_QLEN = 128
class AsyncSystemdNotifier:
""" Boilerplate for proper implementation. This one, however,
also will work. """
def __init__(self):
env_var = os.getenv('NOTIFY_SOCKET')
self._addr = ('\0' + env_var[1:]
......@@ -17,21 +14,28 @@ class AsyncSystemdNotifier:
self._started = False
self._loop = None
self._queue = asyncio.Queue(MAX_QLEN)
self._monitor = False
@property
def started(self):
return self._started
def _drain(self):
try:
while not self._queue.empty():
msg = self._queue.get_nowait()
self._queue.task_done()
while not self._queue.empty():
msg = self._queue.get_nowait()
self._queue.task_done()
try:
self._send(msg)
except BlockingIOError: # pragma: no cover
pass
except OSError:
pass
except BlockingIOError: # pragma: no cover
self._monitor = True
self._loop.add_writer(self._sock.fileno(), self._drain)
break
except OSError:
pass
else:
if self._monitor:
self._monitor = False
self._loop.remove_writer(self._sock.fileno())
def _send(self, data):
return self._sock.sendto(data, socket.MSG_NOSIGNAL, self._addr)
......@@ -43,7 +47,6 @@ class AsyncSystemdNotifier:
try:
self._sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
self._sock.setblocking(0)
self._loop.add_writer(self._sock.fileno(), self._drain)
self._started = True
except OSError:
return False
......@@ -58,7 +61,8 @@ class AsyncSystemdNotifier:
if self._started:
self._started = False
await self._queue.join()
self._loop.remove_writer(self._sock.fileno())
if self._monitor:
self._loop.remove_writer(self._sock.fileno())
self._sock.close()
async def __aenter__(self):
......
......@@ -227,7 +227,7 @@ class STSSocketmapResponder:
stream_reader = netstring.StreamReader(REQUEST_LIMIT)
# Construct queue for responses ordering
queue = asyncio.Queue(QUEUE_LIMIT, loop=self._loop)
queue = asyncio.Queue(QUEUE_LIMIT)
# Create coroutine which awaits for steady responses and sends them
sender = asyncio.ensure_future(self.sender(queue, writer), loop=self._loop)
......
......@@ -7,7 +7,7 @@ with open(path.join(this_directory, 'README.md'), encoding='utf-8') as f:
long_description = f.read() # pylint: disable=invalid-name
setup(name='postfix_mta_sts_resolver',
version='0.7.3',
version='0.7.5',
description='Daemon which provides TLS client policy for Postfix '
'via socketmap, according to domain MTA-STS policy',
url='https://github.com/Snawoot/postfix-mta-sts-resolver',
......