aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jsonrpc/src/server/mod.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/jsonrpc/src/server/mod.rs b/jsonrpc/src/server/mod.rs
index dd176d0..7ff1a8c 100644
--- a/jsonrpc/src/server/mod.rs
+++ b/jsonrpc/src/server/mod.rs
@@ -19,6 +19,7 @@ use response_queue::ResponseQueue;
pub const INVALID_REQUEST_ERROR_MSG: &str = "Invalid request";
pub const FAILED_TO_PARSE_ERROR_MSG: &str = "Failed to parse";
pub const METHOD_NOT_FOUND_ERROR_MSG: &str = "Method not found";
+pub const UNSUPPORTED_JSONRPC_VERSION: &str = "Unsupported jsonrpc version";
struct NewRequest {
srvc_name: String,
@@ -175,6 +176,20 @@ impl Server {
return SanityCheckResult::ErrRes(response);
}
};
+
+ if rpc_msg.jsonrpc != message::JSONRPC_VERSION {
+ let response = message::Response {
+ error: Some(message::Error {
+ code: message::INVALID_REQUEST_ERROR_CODE,
+ message: UNSUPPORTED_JSONRPC_VERSION.to_string(),
+ data: None,
+ }),
+ id: Some(rpc_msg.id),
+ ..Default::default()
+ };
+ return SanityCheckResult::ErrRes(response);
+ }
+
debug!("<-- {rpc_msg}");
// Parse the service name and its method