diff options
author | Richard van der Hoff <1389908+richvdh@users.noreply.github.com> | 2021-03-26 17:33:55 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-26 17:33:55 +0000 |
commit | 7c8402ddb88df09cf1a33b3925c2996926fd0a23 (patch) | |
tree | 07277f2a6392d9759f09966549885caeb9d80749 | |
parent | Make it possible to use dmypy (#9692) (diff) | |
download | synapse-7c8402ddb88df09cf1a33b3925c2996926fd0a23.tar.xz |
Suppress CryptographyDeprecationWarning (#9698)
This warning is somewhat confusing to users, so let's suppress it
Diffstat (limited to '')
-rw-r--r-- | changelog.d/9698.misc | 1 | ||||
-rw-r--r-- | synapse/app/_base.py | 21 | ||||
-rw-r--r-- | synapse/app/generic_worker.py | 9 | ||||
-rw-r--r-- | synapse/app/homeserver.py | 9 |
4 files changed, 26 insertions, 14 deletions
diff --git a/changelog.d/9698.misc b/changelog.d/9698.misc new file mode 100644 index 0000000000..d199e846c5 --- /dev/null +++ b/changelog.d/9698.misc @@ -0,0 +1 @@ +Suppress "CryptographyDeprecationWarning: int_from_bytes is deprecated". diff --git a/synapse/app/_base.py b/synapse/app/_base.py index 43b1f1e94b..3912c8994c 100644 --- a/synapse/app/_base.py +++ b/synapse/app/_base.py @@ -21,8 +21,10 @@ import signal import socket import sys import traceback +import warnings from typing import Awaitable, Callable, Iterable +from cryptography.utils import CryptographyDeprecationWarning from typing_extensions import NoReturn from twisted.internet import defer, error, reactor @@ -195,6 +197,25 @@ def listen_metrics(bind_addresses, port): start_http_server(port, addr=host, registry=RegistryProxy) +def listen_manhole(bind_addresses: Iterable[str], port: int, manhole_globals: dict): + # twisted.conch.manhole 21.1.0 uses "int_from_bytes", which produces a confusing + # warning. It's fixed by https://github.com/twisted/twisted/pull/1522), so + # suppress the warning for now. + warnings.filterwarnings( + action="ignore", + category=CryptographyDeprecationWarning, + message="int_from_bytes is deprecated", + ) + + from synapse.util.manhole import manhole + + listen_tcp( + bind_addresses, + port, + manhole(username="matrix", password="rabbithole", globals=manhole_globals), + ) + + def listen_tcp(bind_addresses, port, factory, reactor=reactor, backlog=50): """ Create a TCP socket for a port and several addresses diff --git a/synapse/app/generic_worker.py b/synapse/app/generic_worker.py index caef394e1d..6139881dbb 100644 --- a/synapse/app/generic_worker.py +++ b/synapse/app/generic_worker.py @@ -147,7 +147,6 @@ from synapse.storage.databases.main.user_directory import UserDirectoryStore from synapse.types import ReadReceipt from synapse.util.async_helpers import Linearizer from synapse.util.httpresourcetree import create_resource_tree -from synapse.util.manhole import manhole from synapse.util.versionstring import get_version_string logger = logging.getLogger("synapse.app.generic_worker") @@ -640,12 +639,8 @@ class GenericWorkerServer(HomeServer): if listener.type == "http": self._listen_http(listener) elif listener.type == "manhole": - _base.listen_tcp( - listener.bind_addresses, - listener.port, - manhole( - username="matrix", password="rabbithole", globals={"hs": self} - ), + _base.listen_manhole( + listener.bind_addresses, listener.port, manhole_globals={"hs": self} ) elif listener.type == "metrics": if not self.get_config().enable_metrics: diff --git a/synapse/app/homeserver.py b/synapse/app/homeserver.py index 244657cb88..3bfe9d507f 100644 --- a/synapse/app/homeserver.py +++ b/synapse/app/homeserver.py @@ -67,7 +67,6 @@ from synapse.storage import DataStore from synapse.storage.engines import IncorrectDatabaseSetup from synapse.storage.prepare_database import UpgradeDatabaseException from synapse.util.httpresourcetree import create_resource_tree -from synapse.util.manhole import manhole from synapse.util.module_loader import load_module from synapse.util.versionstring import get_version_string @@ -288,12 +287,8 @@ class SynapseHomeServer(HomeServer): if listener.type == "http": self._listening_services.extend(self._listener_http(config, listener)) elif listener.type == "manhole": - listen_tcp( - listener.bind_addresses, - listener.port, - manhole( - username="matrix", password="rabbithole", globals={"hs": self} - ), + _base.listen_manhole( + listener.bind_addresses, listener.port, manhole_globals={"hs": self} ) elif listener.type == "replication": services = listen_tcp( |