mirror of
https://github.com/hinto-janai/cuprate.git
synced 2024-12-22 11:39:30 +00:00
rpc-interface: add restricted invariant comments
This commit is contained in:
parent
04cdc72f46
commit
3763dc9693
3 changed files with 20 additions and 1 deletions
|
@ -71,7 +71,12 @@ macro_rules! generate_endpoints_inner {
|
|||
($variant:ident, $handler:ident, $request:expr_2021) => {
|
||||
paste::paste! {
|
||||
{
|
||||
// Check if restricted.
|
||||
// INVARIANT:
|
||||
// The handler functions in `cuprated` depend on this line existing,
|
||||
// the functions themselves do not check if they are being called
|
||||
// from an (un)restricted context.
|
||||
//
|
||||
// This line must be here or all methods will be allowed to be called freely.
|
||||
if [<$variant Request>]::IS_RESTRICTED && $handler.is_restricted() {
|
||||
// TODO: mimic `monerod` behavior.
|
||||
return Err(StatusCode::FORBIDDEN);
|
||||
|
|
|
@ -37,6 +37,13 @@ pub(crate) async fn json_rpc<H: RpcHandler>(
|
|||
|
||||
// Return early if this RPC server is restricted and
|
||||
// the requested method is only for non-restricted RPC.
|
||||
//
|
||||
// INVARIANT:
|
||||
// The handler functions in `cuprated` depend on this line existing,
|
||||
// the functions themselves do not check if they are being called
|
||||
// from an (un)restricted context.
|
||||
//
|
||||
// This line must be here or all methods will be allowed to be called freely.
|
||||
if request.body.is_restricted() && handler.is_restricted() {
|
||||
let error_object = ErrorObject {
|
||||
code: ErrorCode::ServerError(-1 /* TODO */),
|
||||
|
|
|
@ -75,6 +75,13 @@ macro_rules! generate_endpoints_inner {
|
|||
paste::paste! {
|
||||
{
|
||||
// Check if restricted.
|
||||
//
|
||||
// INVARIANT:
|
||||
// The handler functions in `cuprated` depend on this line existing,
|
||||
// the functions themselves do not check if they are being called
|
||||
// from an (un)restricted context.
|
||||
//
|
||||
// This line must be here or all methods will be allowed to be called freely.
|
||||
if [<$variant Request>]::IS_RESTRICTED && $handler.is_restricted() {
|
||||
// TODO: mimic `monerod` behavior.
|
||||
return Err(StatusCode::FORBIDDEN);
|
||||
|
|
Loading…
Reference in a new issue