Module: Specinfra::Command::Module::Ss

Included in:
Amazon::V2022::Port, Amazon::V2::Port, Debian::V8::Port, Redhat::V7::Port, Ubuntu::V18::Port
Defined in:
lib/specinfra/command/module/ss.rb

Instance Method Summary collapse

Instance Method Details

#check_is_listening(port, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/specinfra/command/module/ss.rb', line 5

def check_is_listening(port, options={})
  if options[:local_address]
    pattern = inaddr_any_to_asterisk(options[:local_address]).map { |l| " #{l}:#{port} " }
    pattern = pattern.join('|')
  else
    pattern = ":#{port} "
  end
  "ss #{command_options(options[:protocol])} | grep -E -- #{escape(pattern)}"
end