Merge branch 'develop' into matrix-org-hotfixes
commit
25880bd441
|
@ -0,0 +1 @@
|
||||||
|
Fixes a long standing bug in worker mode where worker information was saved in the devices table instead of the original IP address and user agent.
|
|
@ -0,0 +1 @@
|
||||||
|
Fix 'stuck invites' which happen when we are unable to reject a room invite received over federation.
|
|
@ -21,7 +21,7 @@ from typing import Dict, Iterable, Optional, Set
|
||||||
|
|
||||||
from typing_extensions import ContextManager
|
from typing_extensions import ContextManager
|
||||||
|
|
||||||
from twisted.internet import defer, reactor
|
from twisted.internet import address, defer, reactor
|
||||||
|
|
||||||
import synapse
|
import synapse
|
||||||
import synapse.events
|
import synapse.events
|
||||||
|
@ -206,10 +206,30 @@ class KeyUploadServlet(RestServlet):
|
||||||
|
|
||||||
if body:
|
if body:
|
||||||
# They're actually trying to upload something, proxy to main synapse.
|
# They're actually trying to upload something, proxy to main synapse.
|
||||||
# Pass through the auth headers, if any, in case the access token
|
|
||||||
# is there.
|
# Proxy headers from the original request, such as the auth headers
|
||||||
auth_headers = request.requestHeaders.getRawHeaders(b"Authorization", [])
|
# (in case the access token is there) and the original IP /
|
||||||
headers = {"Authorization": auth_headers}
|
# User-Agent of the request.
|
||||||
|
headers = {
|
||||||
|
header: request.requestHeaders.getRawHeaders(header, [])
|
||||||
|
for header in (b"Authorization", b"User-Agent")
|
||||||
|
}
|
||||||
|
# Add the previous hop the the X-Forwarded-For header.
|
||||||
|
x_forwarded_for = request.requestHeaders.getRawHeaders(
|
||||||
|
b"X-Forwarded-For", []
|
||||||
|
)
|
||||||
|
if isinstance(request.client, (address.IPv4Address, address.IPv6Address)):
|
||||||
|
previous_host = request.client.host.encode("ascii")
|
||||||
|
# If the header exists, add to the comma-separated list of the first
|
||||||
|
# instance of the header. Otherwise, generate a new header.
|
||||||
|
if x_forwarded_for:
|
||||||
|
x_forwarded_for = [
|
||||||
|
x_forwarded_for[0] + b", " + previous_host
|
||||||
|
] + x_forwarded_for[1:]
|
||||||
|
else:
|
||||||
|
x_forwarded_for = [previous_host]
|
||||||
|
headers[b"X-Forwarded-For"] = x_forwarded_for
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = await self.http_client.post_json_get_json(
|
result = await self.http_client.post_json_get_json(
|
||||||
self.main_uri + request.uri.decode("ascii"), body, headers=headers
|
self.main_uri + request.uri.decode("ascii"), body, headers=headers
|
||||||
|
|
|
@ -1092,7 +1092,7 @@ class RoomMemberMasterHandler(RoomMemberHandler):
|
||||||
alg, h = compute_event_reference_hash(invite_event)
|
alg, h = compute_event_reference_hash(invite_event)
|
||||||
invite_hash = (invite_event.event_id, {alg: encode_base64(h)})
|
invite_hash = (invite_event.event_id, {alg: encode_base64(h)})
|
||||||
|
|
||||||
auth_events = invite_event.auth_events + (invite_hash,)
|
auth_events = tuple(invite_event.auth_events) + (invite_hash,)
|
||||||
prev_events = (invite_hash,)
|
prev_events = (invite_hash,)
|
||||||
|
|
||||||
# we cap depth of generated events, to ensure that they are not
|
# we cap depth of generated events, to ensure that they are not
|
||||||
|
|
Loading…
Reference in New Issue