[tarantool-patches] [PATCH 5/5] box/lua/console: Limit lua output for local sessions only

Cyrill Gorcunov gorcunov at gmail.com
Wed Jul 24 01:31:13 MSK 2019


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





More information about the Tarantool-patches mailing list