From a51e93a86893d164d06d34d011375b2032d9d2d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Tue, 19 Nov 2019 16:54:07 +0100 Subject: [PATCH] config: Add a DebugEncryption setting to enable the nio crytpo logs. --- contrib/pantalaimon.conf | 1 + pantalaimon/config.py | 6 ++++++ pantalaimon/main.py | 9 ++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/contrib/pantalaimon.conf b/contrib/pantalaimon.conf index df0cb67..cfee109 100644 --- a/contrib/pantalaimon.conf +++ b/contrib/pantalaimon.conf @@ -2,6 +2,7 @@ LogLevel = Debug SSL = True Notifications = On +DebugEncryption = True [local-matrix] Homeserver = https://localhost:8448 diff --git a/pantalaimon/config.py b/pantalaimon/config.py index 9a1250d..2a01714 100644 --- a/pantalaimon/config.py +++ b/pantalaimon/config.py @@ -38,6 +38,7 @@ class PanConfigParser(configparser.ConfigParser): "IndexEncryptedOnly": "True", "IndexingBatchSize": "100", "HistoryFetchDelay": "3000", + "DebugEncryption": "False", }, converters={ "address": parse_address, @@ -146,11 +147,14 @@ class PanConfig: config_path (str): The path where we should search for a configuration file. filename (str): The name of the file that we should read. + debug_encryption (bool): Should debug logs be enabled for the Matrix + encryption support. """ config_file = attr.ib() log_level = attr.ib(default=None) + debug_encryption = attr.ib(type=bool, default=None) notifications = attr.ib(default=None) servers = attr.ib(init=False, default=attr.Factory(dict)) @@ -172,6 +176,8 @@ class PanConfig: if self.notifications is None: self.notifications = config["Default"].getboolean("Notifications") + self.debug_encryption = config["Default"].getboolean("DebugEncryption") + listen_set = set() try: diff --git a/pantalaimon/main.py b/pantalaimon/main.py index 0879390..d6087f2 100644 --- a/pantalaimon/main.py +++ b/pantalaimon/main.py @@ -20,6 +20,8 @@ from typing import Optional import click import janus import keyring +import logbook +import nio from aiohttp import web from appdirs import user_config_dir, user_data_dir from logbook import StderrHandler @@ -127,10 +129,11 @@ async def message_router(receive_queue, send_queue, proxies): type=click.Choice(["error", "warning", "info", "debug"]), default=None, ) +@click.option("--debug-encryption", is_flag=True) @click.option("-c", "--config", type=click.Path(exists=True)) @click.option("--data-path", type=click.Path(exists=True)) @click.pass_context -def main(context, log_level, config, data_path): +def main(context, log_level, debug_encryption, config, data_path): loop = asyncio.get_event_loop() conf_dir = user_config_dir("pantalaimon", "") @@ -154,6 +157,10 @@ def main(context, log_level, config, data_path): context.fail("Homeserver is not configured.") logger.level = pan_conf.log_level + + if pan_conf.debug_encryption or debug_encryption: + nio.crypto.logger.level = logbook.DEBUG + StderrHandler().push_application() servers = []