mirror of
https://github.com/matrix-construct/construct
synced 2024-06-10 05:58:56 +02:00
ircd:Ⓜ️ Move the event max_size conf item; add a MAX_SIZE constexpr.
This commit is contained in:
parent
931fe2439e
commit
2b72fae7a1
|
@ -15,8 +15,6 @@ namespace ircd::m
|
|||
{
|
||||
struct event;
|
||||
|
||||
extern conf::item<size_t> event_max_size;
|
||||
|
||||
bool my(const id::event &);
|
||||
bool my(const event &);
|
||||
|
||||
|
@ -80,6 +78,9 @@ struct ircd::m::event
|
|||
using closure = std::function<void (const event &)>;
|
||||
using closure_bool = std::function<bool (const event &)>;
|
||||
|
||||
static constexpr size_t MAX_SIZE = 64_KiB;
|
||||
static conf::item<size_t> max_size;
|
||||
|
||||
static ed25519::sig sign(const m::event &);
|
||||
static ed25519::sig sign(json::iov &event, const json::iov &content);
|
||||
static string_view signatures(const mutable_buffer &, json::iov &event, const json::iov &content);
|
||||
|
|
|
@ -10,13 +10,6 @@
|
|||
|
||||
#include <ircd/m/m.h>
|
||||
|
||||
ircd::conf::item<size_t>
|
||||
ircd::m::event_max_size
|
||||
{
|
||||
{ "name", "m.event.max_size" },
|
||||
{ "default", 65507L },
|
||||
};
|
||||
|
||||
ircd::m::id::event
|
||||
ircd::m::event_id(const event &event,
|
||||
id::event::buf &buf)
|
||||
|
@ -51,12 +44,12 @@ ircd::m::check_size(const event &event)
|
|||
serialized(event)
|
||||
};
|
||||
|
||||
if(event_size > size_t(event_max_size))
|
||||
if(event_size > size_t(event::max_size))
|
||||
throw m::BAD_JSON
|
||||
{
|
||||
"Event is %zu bytes which is larger than the maximum %zu bytes",
|
||||
event_size,
|
||||
size_t(event_max_size)
|
||||
size_t(event::max_size)
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -69,7 +62,7 @@ ircd::m::check_size(std::nothrow_t,
|
|||
serialized(event)
|
||||
};
|
||||
|
||||
return event_size <= size_t(event_max_size);
|
||||
return event_size <= size_t(event::max_size);
|
||||
}
|
||||
|
||||
ircd::string_view
|
||||
|
@ -399,6 +392,20 @@ ircd::m::my(const id::event &event_id)
|
|||
// event
|
||||
//
|
||||
|
||||
/// The maximum size of an event we will create. This may also be used in
|
||||
/// some contexts for what we will accept, but the protocol limit and hard
|
||||
/// worst-case buffer size is still event::MAX_SIZE.
|
||||
ircd::conf::item<size_t>
|
||||
ircd::m::event::max_size
|
||||
{
|
||||
{ "name", "m.event.max_size" },
|
||||
{ "default", 65507L },
|
||||
};
|
||||
|
||||
//
|
||||
// event::event
|
||||
//
|
||||
|
||||
ircd::m::event::event(const id &id,
|
||||
const mutable_buffer &buf)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue