ircd:Ⓜ️:vm: Add evaluator identity suite; add #IDENT fault code.

This commit is contained in:
Jason Volk 2023-02-18 17:27:22 -08:00
parent 262bde6fdf
commit c521a20fb3
4 changed files with 21 additions and 0 deletions

View File

@ -15,6 +15,8 @@ namespace ircd::m::vm
{
struct eval;
string_view evaluator(const eval &) noexcept;
string_view loghead(const mutable_buffer &, const eval &);
string_view loghead(const eval &); // single tls buffer

View File

@ -41,4 +41,5 @@ enum ircd::m::vm::fault
BOUNCE = 0x0040, ///< The event is not needed at this time. (#bo)
DONOTWANT = 0x0080, ///< The event will never be needed (cache this). (#dw)
DENIED = 0x0100, ///< Access of evaluator insufficient. (#ad)
IDENT = 0x0200, ///< Identity of evaluator missing. (#id)
};

View File

@ -160,6 +160,7 @@ ircd::m::vm::http_code(const fault &code)
case fault::BOUNCE: break;
case fault::DONOTWANT: break;
case fault::DENIED: return http::FORBIDDEN;
case fault::IDENT: return http::UNAUTHORIZED;
}
return http::INTERNAL_SERVER_ERROR;
@ -180,6 +181,7 @@ ircd::m::vm::reflect(const enum fault &code)
case fault::BOUNCE: return "#BOUNCE";
case fault::DONOTWANT: return "#DONOTWANT";
case fault::DENIED: return "#DENIED";
case fault::IDENT: return "#IDENT";
}
return "??????";

View File

@ -144,6 +144,22 @@ ircd::m::vm::loghead(const mutable_buffer &buf,
};
}
ircd::string_view
ircd::m::vm::evaluator(const eval &eval)
noexcept
{
if(!eval.opts)
return {};
if(eval.opts->user_id)
return eval.opts->user_id;
if(eval.opts->node_id)
return eval.opts->node_id;
return {};
}
//
// eval::eval
//