Skip to content

Commit

Permalink
proxy support
Browse files Browse the repository at this point in the history
  • Loading branch information
Snawoot committed Oct 25, 2018
1 parent a80f549 commit 373ff4b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions postfix_mta_sts_resolver/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ def __init__(self, *, timeout=defaults.TIMEOUT, loop):
self._timeout = timeout
self._resolver = aiodns.DNSResolver(timeout=timeout, loop=loop)
self._http_timeout = aiohttp.ClientTimeout(total=timeout)
self._proxy_info = aiohttp.helpers.proxies_from_env().get('https', None)
if self._proxy_info is None:
self._proxy = None
self._proxy_auth = None
else:
self._proxy = self._proxy_info.proxy
self._proxy_auth = self._proxy_info.proxy_auth

async def resolve(self, domain, last_known_id=None):
if domain.startswith('.'):
Expand Down Expand Up @@ -69,8 +76,12 @@ async def resolve(self, domain, last_known_id=None):

# Fetch actual policy
try:
async with aiohttp.ClientSession(loop=self._loop, timeout=self._http_timeout) as session:
async with session.get(sts_policy_url, allow_redirects=False) as resp:
async with aiohttp.ClientSession(loop=self._loop,
timeout=self._http_timeout) as session:
async with session.get(sts_policy_url,
allow_redirects=False,
proxy=self._proxy,
proxy_auth=self._proxy_auth) as resp:
if resp.status != 200:
raise BadSTSPolicy()
if not is_plaintext(resp.headers.get('Content-Type', '')):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
long_description = f.read()

setup(name='postfix_mta_sts_resolver',
version='0.2.0',
version='0.2.1',
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',
author='Vladislav Yarmak',
Expand Down

0 comments on commit 373ff4b

Please sign in to comment.