From 6b76853910cf0bc640b145fbfe70631db9f2f9bf Mon Sep 17 00:00:00 2001 From: Igor Zolotarev Date: Tue, 5 Mar 2024 17:17:28 +0300 Subject: [PATCH] Fix binding to a localhost --- CHANGELOG.rst | 2 ++ cartridge/confapplier.lua | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c6ebd8159..18f712abf 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -18,6 +18,8 @@ Fixed - Raft failover state transitions. +- Remote control socket doesn't bind to a localhost when different host is available. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Added ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/cartridge/confapplier.lua b/cartridge/confapplier.lua index 1c4eae31f..ea8290b24 100644 --- a/cartridge/confapplier.lua +++ b/cartridge/confapplier.lua @@ -833,7 +833,19 @@ local function init(opts) return nil, InitError:new("Could not resolve advertise uri %s", opts.advertise_uri) end - local ok, err = remote_control.bind(addrinfo[1].host, vars.binary_port, { + local host = addrinfo[1].host + if parts.host ~= 'localhost' then + for _, addr in ipairs(addrinfo) do + if family == 'AF_INET' and addr.host ~= '127.0.0.1' + or family == 'AF_INET6' and addr.host ~= '::1' + then + host = addr.host + break + end + end + end + + local ok, err = remote_control.bind(host, vars.binary_port, { transport = vars.transport, -- '' or 'ssl' ssl_ciphers = vars.ssl_ciphers, ssl_ca_file = vars.ssl_server_ca_file,