From 4b70ae70c73ac909b2d95b82172893829b7595c3 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 24 Apr 2019 21:30:05 -0700 Subject: [PATCH] modules/s_fetch: Use the event origin as fallback host. --- modules/s_fetch.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/s_fetch.cc b/modules/s_fetch.cc index 4c0346e09..4b0b734ec 100644 --- a/modules/s_fetch.cc +++ b/modules/s_fetch.cc @@ -404,7 +404,14 @@ try if(opts.fetch_auth_check && auth_exists < auth_count) { - if(!opts.fetch_auth || !bool(m::fetch::enable) || !eval.opts->node_id) + const net::hostport remote + { + eval.opts->node_id? + eval.opts->node_id: + json::get<"origin"_>(event) + }; + + if(!opts.fetch_auth || !bool(m::fetch::enable) || !remote || my_host(host(remote))) throw vm::error { vm::fault::EVENT, "Failed to fetch auth_events for %s in %s", @@ -412,7 +419,7 @@ try json::get<"room_id"_>(*eval.event_) }; - auth_chain(room, eval.opts->node_id); + auth_chain(room, remote); } const size_t prev_count