summary refs log tree commit diff
path: root/synapse/federation
diff options
context:
space:
mode:
authorJorik Schellekens <joriks@matrix.org>2019-09-05 14:41:04 +0100
committerJorik Schellekens <joriks@matrix.org>2019-09-05 14:42:37 +0100
commit1d65292e94077390af0ad9c5ee8cd8b0db9b357c (patch)
tree4f7724f96634cbb1583754fdcaface62dccd84be /synapse/federation
parentRemove bind_email and bind_msisdn (#5964) (diff)
downloadsynapse-1d65292e94077390af0ad9c5ee8cd8b0db9b357c.tar.xz
Link the send loop with the edus contexts
The contexts were being filtered too early so  the send loop wasn't
being linked to them unless the destination
was whitelisted.
Diffstat (limited to 'synapse/federation')
-rw-r--r--synapse/federation/sender/transaction_manager.py11
-rw-r--r--synapse/federation/units.py3
2 files changed, 11 insertions, 3 deletions
diff --git a/synapse/federation/sender/transaction_manager.py b/synapse/federation/sender/transaction_manager.py
index 62ca6a3e87..42f46394bc 100644
--- a/synapse/federation/sender/transaction_manager.py
+++ b/synapse/federation/sender/transaction_manager.py
@@ -26,6 +26,7 @@ from synapse.logging.opentracing import (
     set_tag,
     start_active_span_follows_from,
     tags,
+    whitelisted_homeserver,
 )
 from synapse.util.metrics import measure_func
 
@@ -59,9 +60,13 @@ class TransactionManager(object):
         # The span_contexts is a generator so that it won't be evaluated if
         # opentracing is disabled. (Yay speed!)
 
-        span_contexts = (
-            extract_text_map(json.loads(edu.get_context())) for edu in pending_edus
-        )
+        span_contexts = []
+        keep_destination = whitelisted_homeserver(destination)
+
+        for edu in pending_edus:
+            span_contexts.append(extract_text_map(json.loads(edu.get_context())))
+            if keep_destination:
+                edu.strip_context()
 
         with start_active_span_follows_from("send_transaction", span_contexts):
 
diff --git a/synapse/federation/units.py b/synapse/federation/units.py
index aa84621206..b4d743cde7 100644
--- a/synapse/federation/units.py
+++ b/synapse/federation/units.py
@@ -41,6 +41,9 @@ class Edu(JsonEncodedObject):
     def get_context(self):
         return getattr(self, "content", {}).get("org.matrix.opentracing_context", "{}")
 
+    def strip_context(self):
+        getattr(self, "content", {})["org.matrix.opentracing_context"] = "{}"
+
 
 class Transaction(JsonEncodedObject):
     """ A transaction is a list of Pdus and Edus to be sent to a remote home