Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Disable IP storage #86

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions synapse/storage/databases/main/client_ips.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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-":
Expand Down
Loading