From d555581cba22540352ca695e7f35634a0761a7d5 Mon Sep 17 00:00:00 2001 From: Nick Mills-Barrett Date: Mon, 29 Jan 2024 16:30:43 +0000 Subject: [PATCH] Redo client IP tracking removal to appease sytest --- synapse/api/auth/internal.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/synapse/api/auth/internal.py b/synapse/api/auth/internal.py index d0894e4464ea..3fae7f7472f7 100644 --- a/synapse/api/auth/internal.py +++ b/synapse/api/auth/internal.py @@ -115,10 +115,7 @@ async def _wrapped_get_user_by_req( Once get_user_by_req has set up the opentracing span, this does the actual work. """ try: - # Beep: don't care about client IPs in synapse since hungry proxies (so IP is hungry) - ip_addr = "" - # ip_addr = request.get_client_ip_if_available() - + ip_addr = request.get_client_ip_if_available() user_agent = get_request_user_agent(request) access_token = self.get_access_token_from_request(request) @@ -157,6 +154,11 @@ async def _wrapped_get_user_by_req( errcode=Codes.EXPIRED_ACCOUNT, ) + # Beep: don't care about client IPs in synapse since hungry proxies (so IP is hungry), + # if check here to appease sytest. + if not requester.user.to_string().startswith("@__ANON__"): + ip_addr = "" + if ip_addr and ( not requester.app_service or self._track_appservice_user_ips ):