From 5e43a48766aab3186d1beb224fa0b4deabb82910 Mon Sep 17 00:00:00 2001 From: Samuel Lorch Date: Sun, 5 Mar 2023 20:51:43 +0100 Subject: [PATCH] check for jsonrpc version --- pkg/jsonrpc/handler.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/jsonrpc/handler.go b/pkg/jsonrpc/handler.go index 27f6162..2af59b4 100644 --- a/pkg/jsonrpc/handler.go +++ b/pkg/jsonrpc/handler.go @@ -40,6 +40,10 @@ func (h *Handler) HandleRequest(ctx context.Context, r io.Reader, w io.Writer) e return respondError(w, "", ErrParse, fmt.Errorf("Parsing Request: %w", err)) } + if req.Jsonrpc != "2.0" { + return respondError(w, "", ErrMethodNotFound, fmt.Errorf("Unsupported Jsonrpc version %v", req.Jsonrpc)) + } + method, ok := h.methods[req.Method] if !ok { return respondError(w, "", ErrMethodNotFound, fmt.Errorf("Unknown Method %v", req.Method))