@@ -14,10 +14,11 @@ namespace ircd::m
1414 extern conf::item<bool > x_matrix_verify_origin;
1515 extern conf::item<bool > x_matrix_verify_destination;
1616
17+ static void cache_warm_origin (const resource::request &);
18+ static pair<string_view> parse_version (const resource::request &);
1719 static string_view authenticate_bridge (const resource::method &, const client &, resource::request &);
1820 static user::id authenticate_user (const resource::method &, const client &, resource::request &);
1921 static string_view authenticate_node (const resource::method &, const client &, resource::request &);
20- static void cache_warm_origin (const resource::request &);
2122}
2223
2324decltype (ircd::m::cache_warmup_time)
@@ -154,6 +155,10 @@ ircd::m::resource::request::request(const method &method,
154155 m::request::x_matrix{authorization.first , authorization.second }:
155156 m::request::x_matrix{}
156157}
158+ ,version
159+ {
160+ parse_version (*this )
161+ }
157162,node_id
158163{
159164 // Server X-Matrix header verified here. Similar to client auth, origin
@@ -391,6 +396,30 @@ catch(const std::exception &e)
391396 };
392397}
393398
399+ ircd::pair<ircd::string_view>
400+ ircd::m::parse_version (const m::resource::request &request)
401+ {
402+ const auto &user_agent
403+ {
404+ request.head .user_agent
405+ };
406+
407+ const auto &[primary, info]
408+ {
409+ split (user_agent, ' ' )
410+ };
411+
412+ const auto &[name, version]
413+ {
414+ split (primary, ' /' )
415+ };
416+
417+ return
418+ {
419+ name, version
420+ };
421+ }
422+
394423// / We can smoothly warmup some memory caches after daemon startup as the
395424// / requests trickle in from remote servers. This function is invoked after
396425// / a remote contacts and reveals its identity with the X-Matrix verification.
0 commit comments