lib/zold/commands/routines/reconnect.rb in zold-0.26.19 vs lib/zold/commands/routines/reconnect.rb in zold-0.29.20
- old
+ new
@@ -18,10 +18,11 @@
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
+require 'shellwords'
require_relative '../remote'
require_relative '../../node/farm'
# Reconnect routine.
# Author:: Yegor Bugayenko (yegor256@gmail.com)
@@ -40,12 +41,12 @@
end
def exec(step = 0)
sleep(60) unless @opts['routine-immediately']
cmd = Remote.new(remotes: @remotes, log: @log, farm: @farm)
- args = ['remote', "--network=#{@opts['network']}", '--ignore-ping']
+ args = ['remote', "--network=#{Shellwords.escape(@opts['network'])}", '--ignore-ping']
score = @farm.best[0]
- args << "--ignore-node=#{score.host}:#{score.port}" if score
+ args << "--ignore-node=#{Shellwords.escape("#{score.host}:#{score.port}")}" if score
cmd.run(args + ['masters']) unless @opts['routine-immediately']
all = @remotes.all
return if @opts['routine-immediately'] && all.empty?
cmd.run(args + ['select'])
if all.count < Remotes::MAX_NODES / 2 || all.any? { |r| r[:errors] > Remotes::TOLERANCE } || (step % 10).zero?