0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-18 16:00:57 +01:00

ircd::resource: Separate ircd:Ⓜ️:resource flags out from abstract.

This commit is contained in:
Jason Volk 2023-03-02 13:59:22 -08:00
parent 91ac6a9269
commit 19c740a182
3 changed files with 46 additions and 15 deletions

View file

@ -43,6 +43,7 @@ struct ircd::m::resource
struct ircd::m::resource::method
:ircd::resource::method
{
enum flag :std::underlying_type_t<ircd::resource::flag>;
using handler = std::function<response (client &, request &)>;
handler function;
@ -53,6 +54,20 @@ struct ircd::m::resource::method
~method() noexcept;
};
/// Matrix resource method option flags. These flags are valued in the upper
/// bits to not conflict with the base ircd::resource flag values.
enum ircd::m::resource::method::flag
:std::underlying_type_t<ircd::resource::flag>
{
/// Method will verify access_token or authentication bearer. This is used
/// on the client-server API.
REQUIRES_AUTH = 0x0001'0000,
/// Method will verify X-Matrix-authorization. This is used on the
/// federation API.
VERIFY_ORIGIN = 0x0002'0000,
};
struct ircd::m::resource::request
:ircd::resource::request
{

View file

@ -43,20 +43,34 @@ struct ircd::resource::method
~method() noexcept;
};
/// Resource method option flags. Flag values enumerated here are restricted
/// to the lower half of the integer. The upper half is reserved for derived
/// resource methods and their own flags.
enum ircd::resource::method::flag
:uint
{
REQUIRES_AUTH = 0x01, //TODO: matrix abstraction bleed.
RATE_LIMITED = 0x02,
VERIFY_ORIGIN = 0x04, //TODO: matrix abstraction bleed.
CONTENT_DISCRETION = 0x08,
DELAYED_ACK = 0x10,
DELAYED_RESPONSE = 0x20,
/// Options governing the frequency of requests are applied to method. If
/// not given, any set rate limiting options or their defaults are ignored.
RATE_LIMITED = 0x0001,
/// Method assumes responsibility for consuming HTTP content off socket.
/// If this flag is not set, all content will be consumed off the socket
/// into a buffer prior to the method call.
CONTENT_DISCRETION = 0x0002,
/// The TCP quick-ack feature will not be used prior to calling the method.
/// If this flag is not set the feature may be used if conditions permit.
DELAYED_ACK = 0x0004,
/// TCP delays will be in use while this method responds to the client on
/// the socket.
DELAYED_RESPONSE = 0x0008,
};
struct ircd::resource::method::opts
{
flag flags {(flag)0};
/// Option flags
std::underlying_type_t<method::flag> flags {0};
/// Timeout specific to this resource; 0 is automatic
seconds timeout {0};

View file

@ -6987,15 +6987,17 @@ console_cmd__resource(opt &out, const string_view &line)
r[method]
};
out << method << " "
<< path
<< std::endl;
out
<< method << " "
<< path
<< std::endl;
out << (m.opts->flags & resource::method::REQUIRES_AUTH? " REQUIRES_AUTH" : "")
<< (m.opts->flags & resource::method::RATE_LIMITED? " RATE_LIMITED" : "")
<< (m.opts->flags & resource::method::VERIFY_ORIGIN? " VERIFY_ORIGIN" : "")
<< (m.opts->flags & resource::method::CONTENT_DISCRETION? " CONTENT_DISCRETION" : "")
<< std::endl;
out
<< (m.opts->flags & m::resource::method::REQUIRES_AUTH? " REQUIRES_AUTH" : "")
<< (m.opts->flags & m::resource::method::VERIFY_ORIGIN? " VERIFY_ORIGIN" : "")
<< (m.opts->flags & resource::method::RATE_LIMITED? " RATE_LIMITED" : "")
<< (m.opts->flags & resource::method::CONTENT_DISCRETION? " CONTENT_DISCRETION" : "")
<< std::endl;
return true;
}