mirror of
https://github.com/matrix-construct/construct
synced 2024-05-19 11:23:45 +02:00
ircd:Ⓜ️:resource: Obtain version information for request if possible.
This commit is contained in:
parent
71b69d6fe9
commit
69f4c2b224
|
@ -47,6 +47,7 @@ struct ircd::m::resource::request
|
||||||
pair<string_view> authorization; // proffering any
|
pair<string_view> authorization; // proffering any
|
||||||
string_view access_token; // proffering user
|
string_view access_token; // proffering user
|
||||||
m::request::x_matrix x_matrix; // proferring server
|
m::request::x_matrix x_matrix; // proferring server
|
||||||
|
pair<string_view> version; // enumeration
|
||||||
|
|
||||||
string_view node_id; // authenticated server
|
string_view node_id; // authenticated server
|
||||||
m::user::id user_id; // authenticated user or bridge pup
|
m::user::id user_id; // authenticated user or bridge pup
|
||||||
|
|
|
@ -14,10 +14,11 @@ namespace ircd::m
|
||||||
extern conf::item<bool> x_matrix_verify_origin;
|
extern conf::item<bool> x_matrix_verify_origin;
|
||||||
extern conf::item<bool> x_matrix_verify_destination;
|
extern conf::item<bool> x_matrix_verify_destination;
|
||||||
|
|
||||||
|
static void cache_warm_origin(const resource::request &);
|
||||||
|
static pair<string_view> parse_version(const resource::request &);
|
||||||
static string_view authenticate_bridge(const resource::method &, const client &, resource::request &);
|
static string_view authenticate_bridge(const resource::method &, const client &, resource::request &);
|
||||||
static user::id authenticate_user(const resource::method &, const client &, resource::request &);
|
static user::id authenticate_user(const resource::method &, const client &, resource::request &);
|
||||||
static string_view authenticate_node(const resource::method &, const client &, resource::request &);
|
static string_view authenticate_node(const resource::method &, const client &, resource::request &);
|
||||||
static void cache_warm_origin(const resource::request &);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
decltype(ircd::m::cache_warmup_time)
|
decltype(ircd::m::cache_warmup_time)
|
||||||
|
@ -154,6 +155,10 @@ ircd::m::resource::request::request(const method &method,
|
||||||
m::request::x_matrix{authorization.first, authorization.second}:
|
m::request::x_matrix{authorization.first, authorization.second}:
|
||||||
m::request::x_matrix{}
|
m::request::x_matrix{}
|
||||||
}
|
}
|
||||||
|
,version
|
||||||
|
{
|
||||||
|
parse_version(*this)
|
||||||
|
}
|
||||||
,node_id
|
,node_id
|
||||||
{
|
{
|
||||||
// Server X-Matrix header verified here. Similar to client auth, origin
|
// Server X-Matrix header verified here. Similar to client auth, origin
|
||||||
|
@ -391,6 +396,30 @@ catch(const std::exception &e)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ircd::pair<ircd::string_view>
|
||||||
|
ircd::m::parse_version(const m::resource::request &request)
|
||||||
|
{
|
||||||
|
const auto &user_agent
|
||||||
|
{
|
||||||
|
request.head.user_agent
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto &[primary, info]
|
||||||
|
{
|
||||||
|
split(user_agent, ' ')
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto &[name, version]
|
||||||
|
{
|
||||||
|
split(primary, '/')
|
||||||
|
};
|
||||||
|
|
||||||
|
return
|
||||||
|
{
|
||||||
|
name, version
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/// We can smoothly warmup some memory caches after daemon startup as the
|
/// We can smoothly warmup some memory caches after daemon startup as the
|
||||||
/// requests trickle in from remote servers. This function is invoked after
|
/// requests trickle in from remote servers. This function is invoked after
|
||||||
/// a remote contacts and reveals its identity with the X-Matrix verification.
|
/// a remote contacts and reveals its identity with the X-Matrix verification.
|
||||||
|
|
Loading…
Reference in a new issue