Module: Arborist::NetworkUtilities
- Included in:
- Arborist::Node::Host, Arborist::Node::Service
- Defined in:
- lib/arborist/mixins.rb
Overview
A collection of utilities for working with network addresses, names, etc.
Constant Summary collapse
- IPADDR_RE =
A union of IPv4 and IPv6 regular expressions.
Regexp.union( IPAddr::RE_IPV4ADDRLIKE, IPAddr::RE_IPV6ADDRLIKE_COMPRESSED, IPAddr::RE_IPV6ADDRLIKE_FULL )
Instance Method Summary collapse
-
#normalize_address(address) ⇒ Object
Return the specified
address
as one or more IPAddr objects.
Instance Method Details
#normalize_address(address) ⇒ Object
Return the specified address
as one or more IPAddr objects.
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 |
# File 'lib/arborist/mixins.rb', line 406 def normalize_address( address ) addresses = [] case address when IPAddr addresses << address when IPADDR_RE addresses << IPAddr.new( address ) when String ip_addr = TCPSocket.gethostbyname( address ) addresses = ip_addr[3..-1].map{|ip| IPAddr.new(ip) } else raise "I don't know how to parse a %p host address (%p)" % [ address.class, address ] end return addresses end |