Tarantool development patches archive
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@gmail.com>
To: tml <tarantool-patches@freelists.org>
Cc: Alexander Turenko <alexander.turenko@tarantool.org>,
	Kirill Yukhin <kyukhin@tarantool.org>,
	Konstantin Osipov <kostja@tarantool.org>,
	Cyrill Gorcunov <gorcunov@gmail.com>
Subject: [tarantool-patches] [PATCH 5/5] box/lua/console: Limit lua output for local sessions only
Date: Wed, 24 Jul 2019 01:31:13 +0300	[thread overview]
Message-ID: <20190723223113.16084-6-gorcunov@gmail.com> (raw)
In-Reply-To: <20190723223113.16084-1-gorcunov@gmail.com>

To make full support of lua mode on remote connection we
need pass this option to remote server. Also we need to
provide a compatibility layer for servers from previous
series and thus recode yaml output on client side.

This will be done in next patches, for now simply limit
the usage of lua output to local sessions only.

Part-of #3834
---
 src/box/lua/console.lua | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/src/box/lua/console.lua b/src/box/lua/console.lua
index db57a6d80..b736eaa57 100644
--- a/src/box/lua/console.lua
+++ b/src/box/lua/console.lua
@@ -129,6 +129,28 @@ local function output_save(fmt, opts)
     }
 end
 
+local function output_verify_remote(greeting)
+    --
+    -- FIXME
+    -- For now we disable operating in Lua output
+    -- mode for remote connections, simply because
+    -- we need to extend output processing and pass
+    -- it into remote peer. Also for old servers which
+    -- won't support Lua more we will need to provide
+    -- compatibility layer and decode yaml manually.
+    --
+    -- Thus we require both output settings (per session
+    -- and by default to be set to yaml).
+    local d = box.session.storage.console_output
+    if (d ~= nil and d["fmt"] == "lua") or
+        (d == nil and ouput_default_handler["fmt"] == "lua") then
+        local msg1 = "Lua mode is not support right now. "
+        local msg2 = "Please switch back to yaml output."
+        return false, msg1 .. msg2
+    end
+    return true, nil
+end
+
 local function format(status, ...)
     local d = box.session.storage.console_output
     if d == nil then
@@ -599,6 +621,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

  parent reply	other threads:[~2019-07-23 22:32 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-23 22:31 [tarantool-patches] [PATCH v4 0/5] box/lua/console: Add initial support for lua output format Cyrill Gorcunov
2019-07-23 22:31 ` [tarantool-patches] [PATCH 1/5] third_party/serpent: Add serpent repo Cyrill Gorcunov
2019-07-24 17:02   ` [tarantool-patches] " Konstantin Osipov
2019-07-24 17:33     ` Cyrill Gorcunov
2019-07-23 22:31 ` [tarantool-patches] [PATCH 2/5] box/lua/console: Add support for lua output format Cyrill Gorcunov
2019-07-23 22:31 ` [tarantool-patches] [PATCH 3/5] box/lua/console: Don't serialize function body Cyrill Gorcunov
2019-07-23 22:31 ` [tarantool-patches] [PATCH 4/5] box/lua/console: Provide output_default function to setup default output Cyrill Gorcunov
2019-07-24 17:10   ` [tarantool-patches] " Konstantin Osipov
2019-07-24 17:11     ` Konstantin Osipov
2019-07-24 17:34       ` Cyrill Gorcunov
2019-07-23 22:31 ` Cyrill Gorcunov [this message]
2019-07-24 17:15   ` [tarantool-patches] Re: [PATCH 5/5] box/lua/console: Limit lua output for local sessions only Konstantin Osipov
2019-07-24 17:35     ` Cyrill Gorcunov
2019-07-24 17:00 ` [tarantool-patches] Re: [PATCH v4 0/5] box/lua/console: Add initial support for lua output format Konstantin Osipov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190723223113.16084-6-gorcunov@gmail.com \
    --to=gorcunov@gmail.com \
    --cc=alexander.turenko@tarantool.org \
    --cc=kostja@tarantool.org \
    --cc=kyukhin@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH 5/5] box/lua/console: Limit lua output for local sessions only' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox