aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/daemon_handler.cpp
diff options
context:
space:
mode:
authortobtoht <tob@featherwallet.org>2026-04-02 20:04:02 +0000
committertobtoht <tob@featherwallet.org>2026-04-02 20:04:02 +0000
commit2953f74a84f534d10fe45d2d4c7002f350e0adbd (patch)
tree8ef5f0c25ee7f0e58af6b159ea596adce6d8fec5 /src/rpc/daemon_handler.cpp
parentee1bbe766317b2197510d038753be62f09c13c00 (diff)
parent7f2cfe9294ec1fa7bece2a8069114c1b6985650f (diff)
downloadmonzero-core-2953f74a84f534d10fe45d2d4c7002f350e0adbd.tar.gz
monzero-core-2953f74a84f534d10fe45d2d4c7002f350e0adbd.tar.xz
monzero-core-2953f74a84f534d10fe45d2d4c7002f350e0adbd.zip
Merge pull request #10389
7f2cfe9 zmq: add restricted rpc mode (selsta) dd0fb6c daemon: warn user on specifiying ZMQ args with --no-zmq (jeffro256)
Diffstat (limited to 'src/rpc/daemon_handler.cpp')
-rw-r--r--src/rpc/daemon_handler.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/rpc/daemon_handler.cpp b/src/rpc/daemon_handler.cpp
index c1e4c10bf..671889ddd 100644
--- a/src/rpc/daemon_handler.cpp
+++ b/src/rpc/daemon_handler.cpp
@@ -27,6 +27,7 @@
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "daemon_handler.h"
+#include "rpc/zmq_restricted_methods.h"
#include <algorithm>
#include <cstring>
@@ -109,12 +110,14 @@ namespace rpc
};
} // anonymous
- DaemonHandler::DaemonHandler(cryptonote::core& c, t_p2p& p2p)
- : m_core(c), m_p2p(p2p)
+ DaemonHandler::DaemonHandler(cryptonote::core& c, t_p2p& p2p, bool restricted)
+ : m_core(c), m_p2p(p2p), m_restricted(restricted)
{
const auto last_sorted = std::is_sorted_until(std::begin(handlers), std::end(handlers));
if (last_sorted != std::end(handlers))
throw std::logic_error{std::string{"ZMQ JSON-RPC handlers map is not properly sorted, see "} + last_sorted->method_name};
+
+ check_blocked_methods_sorted();
}
void DaemonHandler::handle(const GetHeight::Request& req, GetHeight::Response& res)
@@ -930,13 +933,24 @@ namespace rpc
epee::byte_slice DaemonHandler::handle(std::string&& request)
{
- MDEBUG("Handling RPC request: " << request);
+ if (m_restricted)
+ MDEBUG("Handling RPC request");
+ else
+ MDEBUG("Handling RPC request: " << request);
try
{
FullMessage req_full(std::move(request), true);
const std::string request_type = req_full.getRequestType();
+ if (m_restricted && is_blocked_in_restricted_mode(request_type))
+ {
+ Message fail;
+ fail.status = Message::STATUS_FAILED;
+ fail.error_details = "\"" + request_type + "\" is not available in restricted mode.";
+ return FullMessage::getResponse(fail, req_full.getID());
+ }
+
const auto matched_handler = std::lower_bound(std::begin(handlers), std::end(handlers), request_type);
if (matched_handler == std::end(handlers) || matched_handler->method_name != request_type)
return BAD_REQUEST(request_type, req_full.getID());