Skip to content

Commit

Permalink
improved debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
caronc committed Sep 8, 2024
1 parent d98ef35 commit fbdd40f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
24 changes: 22 additions & 2 deletions apprise/plugins/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -1642,9 +1642,11 @@ def server_discovery(self):
# IP address. The Host header in the request should be set to the
# server name, including the port if the server name included one.
host = '{}:{}'.format(
host, self.port if self.port
self.host, self.port if self.port
else self.srv_lookup_default_port)

self.logger.debug(
'Matrix SD - Resolved with Server IP Address Rule: %s', host)
# We're done' use `Host` setting
self.store.set(
self.discovery_key, host,
Expand Down Expand Up @@ -1672,6 +1674,8 @@ def server_discovery(self):

# If we get here, we have our host server
host = f'{host}:{self.port}'
self.logger.debug(
'Matrix SD - Resolved with Server Port Rule: %s', host)
self.store.set(
self.discovery_key, host,
expires=self.discovery_cache_length_sec)
Expand Down Expand Up @@ -1754,6 +1758,10 @@ def server_discovery(self):
delegated_host = '{}:{}'.format(
host, port if port else self.srv_lookup_default_port)

self.logger.debug(
'Matrix SD - Resolved with .well-known IP Rule: %s',
delegated_host)

self.store.set(
self.discovery_key, delegated_host,
expires=self.discovery_cache_length_sec)
Expand Down Expand Up @@ -1782,6 +1790,9 @@ def server_discovery(self):

# If we get here, we have our host server
_host = f'{_host}:{port}'
self.logger.debug(
'Matrix SD - Resolved with .well-known Port Rule: %s',
_host)
self.store.set(
self.discovery_key, _host,
expires=self.discovery_cache_length_sec)
Expand All @@ -1806,6 +1817,9 @@ def server_discovery(self):

if _host:
# Return our response
self.logger.debug(
'Matrix SD - Resolved with SRV Rule: %s',
_host)
self.store.set(
self.discovery_key, _host,
expires=self.discovery_cache_length_sec)
Expand All @@ -1827,7 +1841,7 @@ def server_discovery(self):
if not _host:
# Could not resolve host
self.logger.warning(
'Matrix %s A query was unresolvable;'
'Matrix %s A/AAAA/CNAME query was unresolvable;'
' delegation ignored', _host)
self.store.set(
self.discovery_key, '',
Expand All @@ -1838,6 +1852,12 @@ def server_discovery(self):
_host = '{}:{}'.format(
_host, self.port if self.port
else self.srv_lookup_default_port)

self.logger.debug(
'Matrix SD - Resolved with DNS Lookup Rule: %s', _host)
self.store.set(
self.discovery_key, _host,
expires=self.discovery_cache_length_sec)
return _host

def __srv_lookup(self, query):
Expand Down
3 changes: 3 additions & 0 deletions apprise/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1825,6 +1825,9 @@ def resolve_host(hostname, timeout=5, family=None, underscore=True):
# Parse the result to find the SRV record
for res in result:
if res[0] in family:
logger.debug(
'socket.getaddrinfo %s resolved to %s',
hostname, res[4][0])
return res[4][0]

except (socket.gaierror, socket.timeout) as e:
Expand Down

0 comments on commit fbdd40f

Please sign in to comment.