summary refs log tree commit diff
diff options
context:
space:
mode:
authorJorik Schellekens <joriks@matrix.org>2019-07-11 18:21:51 +0100
committerJorik Schellekens <joriks@matrix.org>2019-07-17 14:20:22 +0100
commit62da3aa0afdfbb18559f4ab5d97ae2ebd7281a48 (patch)
treef3afaa89dbf215c6d964eb976b5714775aa37e17
parentMove opentracing setters (diff)
downloadsynapse-62da3aa0afdfbb18559f4ab5d97ae2ebd7281a48.tar.xz
Move whitelisting
-rw-r--r--synapse/logging/opentracing.py57
1 files changed, 30 insertions, 27 deletions
diff --git a/synapse/logging/opentracing.py b/synapse/logging/opentracing.py
index dc49fc3cd5..e9dbef0675 100644
--- a/synapse/logging/opentracing.py
+++ b/synapse/logging/opentracing.py
@@ -119,6 +119,36 @@ def init_tracer(config):
     tags = opentracing.tags
 
 
+##### Whitelisting
+
+
+@only_if_tracing
+def set_homeserver_whitelist(homeserver_whitelist):
+    """Sets the homeserver whitelist
+
+    Args:
+        homeserver_whitelist (iterable of strings): regex of whitelisted homeservers
+    """
+    global _homeserver_whitelist
+    if homeserver_whitelist:
+        # Makes a single regex which accepts all passed in regexes in the list
+        _homeserver_whitelist = re.compile(
+            "({})".format(")|(".join(homeserver_whitelist))
+        )
+
+
+@only_if_tracing
+def whitelisted_homeserver(destination):
+    """Checks if a destination matches the whitelist
+
+    Args:
+        destination (String)"""
+    global _homeserver_whitelist
+    if _homeserver_whitelist:
+        return _homeserver_whitelist.match(destination)
+    return False
+
+
 ##### Start spans and scopes
 
 # Could use kwargs but I want these to be explicit
@@ -279,33 +309,6 @@ def set_operation_name(operation_name):
 
 
 @only_if_tracing
-def set_homeserver_whitelist(homeserver_whitelist):
-    """Sets the homeserver whitelist
-
-    Args:
-        homeserver_whitelist (iterable of strings): regex of whitelisted homeservers
-    """
-    global _homeserver_whitelist
-    if homeserver_whitelist:
-        # Makes a single regex which accepts all passed in regexes in the list
-        _homeserver_whitelist = re.compile(
-            "({})".format(")|(".join(homeserver_whitelist))
-        )
-
-
-@only_if_tracing
-def whitelisted_homeserver(destination):
-    """Checks if a destination matches the whitelist
-
-    Args:
-        destination (String)"""
-    global _homeserver_whitelist
-    if _homeserver_whitelist:
-        return _homeserver_whitelist.match(destination)
-    return False
-
-
-@only_if_tracing
 def inject_active_span_twisted_headers(headers, destination):
     """
     Injects a span context into twisted headers inplace