Method: Rex::Ui::Text::DispatcherShell::CommandDispatcher#tab_complete_source_address

Defined in:
lib/rex/ui/text/dispatcher_shell.rb

#tab_complete_source_addressObject

Return a list of possible source addresses for tab completion.



362
363
364
365
366
367
368
369
370
371
372
# File 'lib/rex/ui/text/dispatcher_shell.rb', line 362

def tab_complete_source_address
  addresses = [Rex::Socket.source_address]
  # getifaddrs was introduced in 2.1.2
  if ::Socket.respond_to?(:getifaddrs)
    ifaddrs = ::Socket.getifaddrs.select do |ifaddr|
      ifaddr.addr && ifaddr.addr.ip?
    end
    addresses += ifaddrs.map { |ifaddr| ifaddr.addr.ip_address }
  end
  addresses
end