From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 4699120BED for ; Fri, 12 Jul 2019 15:05:15 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9wXN_toRdX65 for ; Fri, 12 Jul 2019 15:05:15 -0400 (EDT) Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id F0BA120BBD for ; Fri, 12 Jul 2019 15:05:14 -0400 (EDT) Received: by mail-lf1-f67.google.com with SMTP id z15so2850591lfh.13 for ; Fri, 12 Jul 2019 12:05:14 -0700 (PDT) From: Cyrill Gorcunov Subject: [tarantool-patches] [PATCH 3/3] box/lua/console: Verify remote protocol for compatibility Date: Fri, 12 Jul 2019 22:04:38 +0300 Message-Id: <20190712190438.32349-4-gorcunov@gmail.com> In-Reply-To: <20190712190438.32349-1-gorcunov@gmail.com> References: <20190712190438.32349-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tml Cc: Alexander Turenko , Kirill Yukhin , Konstantin Osipov , Cyrill Gorcunov New versions of tarantool use binary protocol to negotiate with remote servers where all data can be properly serialized by the serpent engine. In turn old instances continue shipping yaml encoded data via text protocol which we simply can't map into lua form. Thus when we connect to a peer make sure that the data it will provide us is supported. Part-of #3834 --- src/box/lua/console.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/box/lua/console.lua b/src/box/lua/console.lua index 7c3b608cb..a9ff6f9a7 100644 --- a/src/box/lua/console.lua +++ b/src/box/lua/console.lua @@ -87,6 +87,22 @@ local function output_save(fmt, opts) } end +local function output_verify_remote(greeting) + -- + -- In case if remote peer is operating over + -- old yaml protocol we are unable to decode + -- it to non-yaml serializers. + if greeting.protocol == 'Lua console' then + local d = box.session.storage.console_output + if d ~= nil and d["fmt"] == "lua" then + local msg1 = "Peer uses deprecated '%s' protocol. " + local msg2 = "Switch output to 'yaml' format to proceed." + return false, msg1:format(greeting.protocol) .. msg2 + end + end + return true, nil +end + local function format(status, ...) local d = box.session.storage.console_output -- @@ -572,6 +588,14 @@ local function connect(uri, opts) log.verbose(greeting) box.error(box.error.NO_CONNECTION) end + + local ok, res = output_verify_remote(greeting) + if not ok then + connection:close() + pcall(self.on_client_disconnect, self) + error(res) + end + local remote if greeting.protocol == 'Lua console' then remote = wrap_text_socket(connection, u, -- 2.20.1