From e1b0a0f6517b332eb3ccce0276c821deab4ef658 Mon Sep 17 00:00:00 2001 From: Nick Mills-Barrett Date: Thu, 7 Mar 2024 15:47:16 +0000 Subject: [PATCH] Disable IP storage via environment variable Env var because it avoids fiddling with a tonne of tests. --- synapse/storage/databases/main/client_ips.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/synapse/storage/databases/main/client_ips.py b/synapse/storage/databases/main/client_ips.py index 8be1511859c9..6563e61074fa 100644 --- a/synapse/storage/databases/main/client_ips.py +++ b/synapse/storage/databases/main/client_ips.py @@ -13,6 +13,7 @@ # limitations under the License. import logging +from os import environ from typing import TYPE_CHECKING, Dict, List, Mapping, Optional, Tuple, Union, cast import attr @@ -42,6 +43,8 @@ # 120 seconds == 2 minutes LAST_SEEN_GRANULARITY = 120 * 1000 +DISABLE_CLIENT_IP_STORAGE = environ.get("SYNAPSE_DISABLE_CLIENT_IP_STORAGE") == "true" + @attr.s(slots=True, frozen=True, auto_attribs=True) class DeviceLastConnectionInfo: @@ -586,6 +589,10 @@ async def insert_client_ip( device_id: Optional[str], now: Optional[int] = None, ) -> None: + # Beep: don't bother storing client IPs at all (if env set) + if DISABLE_CLIENT_IP_STORAGE: + return + # The sync proxy continuously triggers /sync even if the user is not # present so should be excluded from user_ips entries. if user_agent == "sync-v3-proxy-":