0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-05-29 00:03:45 +02:00

ircd:Ⓜ️:fed: Apply the canon service to all remotes without a service string.

This commit is contained in:
Jason Volk 2020-03-05 20:10:55 -08:00
parent 14cce54b1f
commit 0a90b4d4cc
9 changed files with 104 additions and 33 deletions

View file

@ -13,6 +13,7 @@
namespace ircd::m::fed
{
net::hostport matrix_service(net::hostport);
id::event::buf fetch_head(const id::room &room_id, const net::hostport &remote, const id::user &);
id::event::buf fetch_head(const id::room &room_id, const net::hostport &remote);
}
@ -35,3 +36,10 @@ namespace ircd::m::fed
#include "public_rooms.h"
#include "send.h"
#include "groups.h"
inline ircd::net::hostport
ircd::m::fed::matrix_service(net::hostport remote)
{
net::service(remote) = net::service(remote)?: m::canon_service;
return remote;
}

View file

@ -60,7 +60,10 @@ ircd::m::fed::groups::publicised::publicised(const string_view &node,
return server::request
{
opts.remote, std::move(opts.out), std::move(opts.in), opts.sopts
matrix_service(opts.remote),
std::move(opts.out),
std::move(opts.in),
opts.sopts
};
}()}
{
@ -131,7 +134,10 @@ ircd::m::fed::send::send(const string_view &txnid,
return server::request
{
opts.remote, std::move(opts.out), std::move(opts.in), opts.sopts
matrix_service(opts.remote),
std::move(opts.out),
std::move(opts.in),
opts.sopts
};
}()}
{
@ -198,7 +204,10 @@ ircd::m::fed::public_rooms::public_rooms(const net::hostport &remote,
return server::request
{
opts.remote, std::move(opts.out), std::move(opts.in), opts.sopts
matrix_service(opts.remote),
std::move(opts.out),
std::move(opts.in),
opts.sopts
};
}()}
{
@ -275,7 +284,10 @@ ircd::m::fed::frontfill::frontfill(const room::id &room_id,
return server::request
{
opts.remote, std::move(opts.out), std::move(opts.in), opts.sopts
matrix_service(opts.remote),
std::move(opts.out),
std::move(opts.in),
opts.sopts
};
}()}
{
@ -366,7 +378,10 @@ ircd::m::fed::backfill::backfill(const room::id &room_id,
return server::request
{
opts.remote, std::move(opts.out), std::move(opts.in), opts.sopts
matrix_service(opts.remote),
std::move(opts.out),
std::move(opts.in),
opts.sopts
};
}()}
{
@ -430,7 +445,10 @@ ircd::m::fed::state::state(const room::id &room_id,
return server::request
{
opts.remote, std::move(opts.out), std::move(opts.in), opts.sopts
matrix_service(opts.remote),
std::move(opts.out),
std::move(opts.in),
opts.sopts
};
}()}
{
@ -490,7 +508,10 @@ ircd::m::fed::query_auth::query_auth(const m::room::id &room_id,
return server::request
{
opts.remote, std::move(opts.out), std::move(opts.in), opts.sopts
matrix_service(opts.remote),
std::move(opts.out),
std::move(opts.in),
opts.sopts
};
}()}
{
@ -555,7 +576,10 @@ ircd::m::fed::event_auth::event_auth(const m::room::id &room_id,
return server::request
{
opts.remote, std::move(opts.out), std::move(opts.in), opts.sopts
matrix_service(opts.remote),
std::move(opts.out),
std::move(opts.in),
opts.sopts
};
}()}
{
@ -609,7 +633,10 @@ ircd::m::fed::event::event(const m::event::id &event_id,
return server::request
{
opts.remote, std::move(opts.out), std::move(opts.in), opts.sopts
matrix_service(opts.remote),
std::move(opts.out),
std::move(opts.in),
opts.sopts
};
}()}
{
@ -665,7 +692,10 @@ ircd::m::fed::invite::invite(const room::id &room_id,
return server::request
{
opts.remote, std::move(opts.out), std::move(opts.in), opts.sopts
matrix_service(opts.remote),
std::move(opts.out),
std::move(opts.in),
opts.sopts
};
}()}
{
@ -721,7 +751,10 @@ ircd::m::fed::invite2::invite2(const room::id &room_id,
return server::request
{
opts.remote, std::move(opts.out), std::move(opts.in), opts.sopts
matrix_service(opts.remote),
std::move(opts.out),
std::move(opts.in),
opts.sopts
};
}()}
{
@ -777,7 +810,10 @@ ircd::m::fed::send_join::send_join(const room::id &room_id,
return server::request
{
opts.remote, std::move(opts.out), std::move(opts.in), opts.sopts
matrix_service(opts.remote),
std::move(opts.out),
std::move(opts.in),
opts.sopts
};
}()}
{
@ -843,7 +879,10 @@ ircd::m::fed::make_join::make_join(const room::id &room_id,
return server::request
{
opts.remote, std::move(opts.out), std::move(opts.in), opts.sopts
matrix_service(opts.remote),
std::move(opts.out),
std::move(opts.in),
opts.sopts
};
}()}
{
@ -976,7 +1015,10 @@ ircd::m::fed::user::keys::query::query(const json::object &content,
return server::request
{
opts.remote, std::move(opts.out), std::move(opts.in), opts.sopts
matrix_service(opts.remote),
std::move(opts.out),
std::move(opts.in),
opts.sopts
};
}()}
{
@ -1155,7 +1197,10 @@ ircd::m::fed::user::keys::claim::claim(const json::object &content,
return server::request
{
opts.remote, std::move(opts.out), std::move(opts.in), opts.sopts
matrix_service(opts.remote),
std::move(opts.out),
std::move(opts.in),
opts.sopts
};
}()}
{
@ -1268,7 +1313,10 @@ ircd::m::fed::user::devices::devices(const id::user &user_id,
return server::request
{
opts.remote, std::move(opts.out), std::move(opts.in), opts.sopts
matrix_service(opts.remote),
std::move(opts.out),
std::move(opts.in),
opts.sopts
};
}()}
{
@ -1381,7 +1429,10 @@ ircd::m::fed::query::query(const string_view &type,
return server::request
{
opts.remote, std::move(opts.out), std::move(opts.in), opts.sopts
matrix_service(opts.remote),
std::move(opts.out),
std::move(opts.in),
opts.sopts
};
}()}
{
@ -1452,7 +1503,10 @@ ircd::m::fed::key::keys::keys(const server_key &server_key,
return server::request
{
opts.remote, std::move(opts.out), std::move(opts.in), opts.sopts
matrix_service(opts.remote),
std::move(opts.out),
std::move(opts.in),
opts.sopts
};
}()}
{
@ -1513,7 +1567,10 @@ ircd::m::fed::key::query::query(const vector_view<const server_key> &keys,
return server::request
{
opts.remote, std::move(opts.out), std::move(opts.in), opts.sopts
matrix_service(opts.remote),
std::move(opts.out),
std::move(opts.in),
opts.sopts
};
}()}
{
@ -1589,7 +1646,10 @@ ircd::m::fed::version::version(const mutable_buffer &buf,
return server::request
{
opts.remote, std::move(opts.out), std::move(opts.in), opts.sopts
matrix_service(opts.remote),
std::move(opts.out),
std::move(opts.in),
opts.sopts
};
}()}
{

View file

@ -454,7 +454,7 @@ ircd::m::feds::for_each_in_room(const opts &opts,
const auto errmsg
{
server::errmsg(origin)
server::errmsg(fed::matrix_service(origin))
};
if(opts.closure_cached_errors || !errmsg) try
@ -495,7 +495,7 @@ ircd::m::feds::for_one(const string_view &origin,
const auto errmsg
{
server::errmsg(origin)
server::errmsg(fed::matrix_service(origin))
};
if(opts.closure_cached_errors || !errmsg) try

View file

@ -585,7 +585,7 @@ ircd::m::fetch::select_random_origin(request &request)
return false;
// Don't want to use a peer marked with an error by ircd::server
if(ircd::server::errmsg(origin))
if(ircd::server::errmsg(fed::matrix_service(origin)))
return false;
return true;

View file

@ -81,7 +81,7 @@ try
{
// If we have an error cached from previously not being able to
// contact this origin we can clear that now that they're alive.
server::errclear(request.origin);
server::errclear(fed::matrix_service(request.origin));
// The origin was verified so we can invoke the cache warming now.
cache_warm_origin(request);

View file

@ -117,7 +117,7 @@ const
size_t ret{0};
for_each([&ret](const string_view &server)
{
ret += !ircd::empty(server::errmsg(server));
ret += !ircd::empty(server::errmsg(fed::matrix_service(server)));
});
return ret;
@ -134,7 +134,7 @@ const
for_each([&ret](const string_view &hostport)
{
ret += bool(server::exists(hostport));
ret += bool(server::exists(fed::matrix_service(hostport)));
});
assert(ret >= 0L);

View file

@ -4962,7 +4962,7 @@ console_cmd__peer(opt &out, const string_view &line)
{
auto &peer
{
server::find(hostport)
server::find(m::fed::matrix_service(hostport))
};
print_head();
@ -5090,7 +5090,7 @@ console_cmd__peer__error__clear(opt &out, const string_view &line)
const auto cleared
{
server::errclear(hp)
server::errclear(m::fed::matrix_service(hp))
};
out << std::boolalpha << cleared << std::endl;
@ -9377,7 +9377,7 @@ console_cmd__room__origins__random(opt &out, const string_view &line)
const auto ok{[&noerror]
(const string_view &origin)
{
if(noerror && ircd::server::errmsg(origin))
if(noerror && server::errmsg(m::fed::matrix_service(origin)))
return false;
return true;

View file

@ -190,7 +190,7 @@ send_to_room(const m::event &event,
auto it{nodes.lower_bound(origin)};
if(it == end(nodes) || it->first != origin)
{
if(server::errmsg(origin))
if(server::errmsg(m::fed::matrix_service(origin)))
return;
it = nodes.emplace_hint(it, origin, origin);
@ -224,7 +224,7 @@ send_to_user(const m::event &event,
auto it{nodes.lower_bound(remote)};
if(it == end(nodes) || it->first != remote)
{
if(server::errmsg(remote))
if(server::errmsg(m::fed::matrix_service(remote)))
return;
it = nodes.emplace_hint(it, remote, remote);
@ -264,7 +264,7 @@ send_from_user(const m::event &event,
auto it{nodes.lower_bound(origin)};
if(it == end(nodes) || it->first != origin)
{
if(server::errmsg(origin))
if(server::errmsg(m::fed::matrix_service(origin)))
return true;
it = nodes.emplace_hint(it, origin, origin);

View file

@ -384,7 +384,10 @@ ircd::m::media::file::download(const mutable_buffer &head_buf,
//TODO: --- This should use the progress callback to build blocks
server::request remote_request
{
remote, { out_head }, { in_head, {} }, opts
fed::matrix_service(remote),
{ out_head },
{ in_head, {} },
opts
};
if(!remote_request.wait(seconds(download_timeout), std::nothrow))