0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-25 05:18:23 +02:00

ircd:Ⓜ️ Simplify various interfaces using string rather than net::hostport remotes.

This commit is contained in:
Jason Volk 2020-03-07 17:09:09 -08:00
parent 9cceed8d34
commit c0a5a7a89e
8 changed files with 21 additions and 28 deletions

View file

@ -15,8 +15,8 @@ namespace ircd::m::fed
{
net::hostport matrix_service(net::hostport);
string_view fetch_well_known(const mutable_buffer &out, const string_view &origin);
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);
id::event::buf fetch_head(const id::room &room_id, const string_view &remote, const id::user &);
id::event::buf fetch_head(const id::room &room_id, const string_view &remote);
}
#include "version.h"

View file

@ -56,8 +56,8 @@ struct ircd::m::room::aliases::cache
static bool for_each(const string_view &server, const closure_bool &);
static bool for_each(const closure_bool &);
static void fetch(const alias &, const net::hostport &remote);
static bool fetch(std::nothrow_t, const alias &, const net::hostport &remote);
static void fetch(const alias &, const string_view &remote);
static bool fetch(std::nothrow_t, const alias &, const string_view &remote);
static bool get(std::nothrow_t, const alias &, const id::closure &);
static void get(const alias &, const id::closure &);

View file

@ -19,7 +19,7 @@ struct ircd::m::user::profile
m::user user;
static void fetch(const m::user &, const net::hostport &, const string_view &key = {});
static void fetch(const m::user &, const string_view &, const string_view &key = {});
public:
bool for_each(const closure_bool &) const;

View file

@ -1675,7 +1675,7 @@ fetch_head_timeout
ircd::m::event::id::buf
ircd::m::fed::fetch_head(const id::room &room_id,
const net::hostport &remote)
const string_view &remote)
{
const m::room room
{
@ -1702,7 +1702,7 @@ ircd::m::fed::fetch_head(const id::room &room_id,
ircd::m::event::id::buf
ircd::m::fed::fetch_head(const id::room &room_id,
const net::hostport &remote,
const string_view &remote,
const id::user &user_id)
{
const unique_buffer<mutable_buffer> buf

View file

@ -219,7 +219,7 @@ try
assert(!query_server.empty());
m::fed::key::opts opts;
opts.remote = net::hostport{query_server};
opts.remote = query_server;
opts.dynamic = true;
const unique_buffer<mutable_buffer> buf
{

View file

@ -283,29 +283,23 @@ ircd::m::room::aliases::cache::get(std::nothrow_t,
return ret;
}
namespace ircd::m
{
thread_local char room_aliases_cache_fetch_hpbuf[384];
}
bool
IRCD_MODULE_EXPORT
ircd::m::room::aliases::cache::fetch(std::nothrow_t,
const alias &a,
const net::hostport &hp)
const string_view &remote)
try
{
fetch(a, hp);
fetch(a, remote);
return true;
}
catch(const std::exception &e)
{
thread_local char buf[384];
log::error
{
log, "Failed to fetch room_id for %s from %s :%s",
string_view{a},
string(buf, hp),
remote,
e.what(),
};
@ -364,7 +358,7 @@ ircd::m::room::aliases::cache::for_each(const closure_bool &c)
void
IRCD_MODULE_EXPORT
ircd::m::room::aliases::cache::fetch(const alias &alias,
const net::hostport &hp)
const string_view &remote)
try
{
const unique_buffer<mutable_buffer> buf
@ -373,7 +367,7 @@ try
};
m::fed::query::opts opts;
opts.remote = hp;
opts.remote = remote;
opts.dynamic = true;
m::fed::query::directory request
@ -401,7 +395,7 @@ try
throw m::NOT_FOUND
{
"Server '%s' does not know room_id for %s",
string(room_aliases_cache_fetch_hpbuf, hp),
remote,
string_view{alias},
};
@ -413,7 +407,7 @@ catch(const ctx::timeout &e)
{
http::GATEWAY_TIMEOUT, "M_ROOM_ALIAS_TIMEOUT",
"Server '%s' did not respond with a room_id for %s in time",
string(room_aliases_cache_fetch_hpbuf, hp),
remote,
string_view{alias},
};
}
@ -423,7 +417,7 @@ catch(const server::unavailable &e)
{
http::BAD_GATEWAY, "M_ROOM_ALIAS_UNAVAILABLE",
"Server '%s' is not available to query a room_id for %s",
string(room_aliases_cache_fetch_hpbuf, hp),
remote,
string_view{alias},
};
}

View file

@ -123,7 +123,7 @@ const
void
IRCD_MODULE_EXPORT
ircd::m::user::profile::fetch(const m::user &user,
const net::hostport &remote,
const string_view &remote,
const string_view &key)
{
const unique_buffer<mutable_buffer> buf

View file

@ -14087,14 +14087,13 @@ console_cmd__fed__key__query(opt &out, const string_view &line)
bool
console_cmd__fed__version(opt &out, const string_view &line)
{
const net::hostport remote
const params param{line, " ",
{
token(line, ' ', 0)
};
"remote"
}};
m::fed::version::opts opts;
opts.remote = remote;
opts.remote = param.at("remote");
const unique_mutable_buffer buf
{
16_KiB