# File common/lib/symbiosis/host.rb, line 28 def self.ip_addresses ip_addresses = [] # # We only want addresses associated with the primary interface. # interface = self.primary_interface return [] if interface.nil? # # Call ip with a set of arguments that returns an easy-to-parse list of # IPs, for both IPv4 and 6, for the primary interface, with global scope. # netlink_socket.addr.list(:index => interface.index) do |ifaddr| next unless 0 == ifaddr.scope if ifaddr.respond_to?("local") and ifaddr.local.is_a?(::IPAddr) ip_addresses << IPAddr.new(ifaddr.local.to_s) else ip_addresses << IPAddr.new(ifaddr.address.to_s) end end ip_addresses end