Skip to content

Commit

Permalink
Dont spam logs with invalid addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
b0d0nne11 committed Jan 29, 2018
1 parent ee882c0 commit 08d32e7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions flanker/addresslib/address.py
Expand Up @@ -249,7 +249,7 @@ def parse_list(address_list, strict=False, as_tuple=False, metrics=False):
return _parse_list_result(as_tuple, AddressList(), [address_list], mtimes)

if not strict:
_log.info('relaxed parsing is not available for discrete lists, ignoring')
_log.debug('relaxed parsing is not available for discrete lists, ignoring')

return parse_discrete_list(address_list, as_tuple=as_tuple, metrics=True)

Expand Down Expand Up @@ -294,15 +294,15 @@ def validate_address(addr_spec, metrics=False, skip_remote_checks=False):
paddr = parse(addr_spec, addr_spec_only=True, strict=True)
mtimes['parsing'] = time() - bstart
if paddr is None:
_log.warning('failed parse check for %s', addr_spec)
_log.debug('failed parse check for %s', addr_spec)
return None, mtimes

# lookup the TLD
bstart = time()
tld = get_tld(paddr.hostname, fail_silently=True, fix_protocol=True)
mtimes['tld_lookup'] = time() - bstart
if tld is None:
_log.warning('failed tld check for %s', addr_spec)
_log.debug('failed tld check for %s', addr_spec)
return None, mtimes

if skip_remote_checks:
Expand All @@ -314,15 +314,15 @@ def validate_address(addr_spec, metrics=False, skip_remote_checks=False):
mtimes['dns_lookup'] = mx_metrics['dns_lookup']
mtimes['mx_conn'] = mx_metrics['mx_conn']
if exchanger is None:
_log.warning('failed mx check for %s', addr_spec)
_log.debug('failed mx check for %s', addr_spec)
return None, mtimes

# lookup custom local-part grammar if it exists
bstart = time()
plugin = plugin_for_esp(exchanger)
mtimes['custom_grammar'] = time() - bstart
if plugin and plugin.validate(paddr) is False:
_log.warning('failed custom grammer check for %s/%s', addr_spec, plugin.__name__)
_log.debug('failed custom grammer check for %s/%s', addr_spec, plugin.__name__)
return None, mtimes

return paddr, mtimes
Expand Down

0 comments on commit 08d32e7

Please sign in to comment.