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

Commit

Permalink
Disable IP storage via environment variable
Browse files Browse the repository at this point in the history
Env var because it avoids fiddling with a tonne of tests.
  • Loading branch information
Fizzadar committed Mar 7, 2024
1 parent 8216175 commit e1b0a0f
Showing 1 changed file with 7 additions and 0 deletions.
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

0 comments on commit e1b0a0f

Please sign in to comment.