daemon: Intercept well-known requests.

Some clients might try to use homeserver discovery despite being
provided with a homeserver and only the local part of a MXID. To hinder
them from going around pantalaimon intercept well-known requests and
return a 404.
This commit is contained in:
Damir Jelić 2020-02-14 12:55:35 +01:00
parent f3107e2d6b
commit 45b823eac6
2 changed files with 10 additions and 0 deletions

View File

@ -987,6 +987,14 @@ class ProxyDaemon:
return web.json_response(result, headers=CORS_HEADERS, status=200)
async def well_known(self, _):
"""Intercept well-known requests
Clients might make this request before logging in and override the
homeserver setting set by the user.
"""
return web.Response(status=404)
async def shutdown(self, _):
"""Shut the daemon down closing all the client sessions it has.

View File

@ -70,6 +70,8 @@ async def init(data_dir, server_conf, send_queue, recv_queue):
proxy.send_message,
),
web.post("/_matrix/client/r0/user/{user_id}/filter", proxy.filter),
web.post("/.well-known/matrix/client", proxy.well_known),
web.get("/.well-known/matrix/client", proxy.well_known),
web.post("/_matrix/client/r0/search", proxy.search),
web.options("/_matrix/client/r0/search", proxy.search_opts),
]