Project

General

Profile

Bug #4753 » 0001-doc-ipaddr.patch

sz (Sandor Szücs), 05/21/2011 08:50 PM

View differences:

lib/ipaddr.rb
unless Socket.const_defined? "AF_INET6"
class Socket < BasicSocket
# IPv6 protocol family
AF_INET6 = Object.new
end
......
end
alias getaddress_orig getaddress
# Returns a +String+ based representation of a valid DNS hostname,
# IPv4 or IPv6 address.
#
# IPSocket.getaddress 'localhost' #=> "::1"
# IPSocket.getaddress 'broadcasthost' #=> "255.255.255.255"
# IPSocket.getaddress 'www.ruby-lang.org' #=> "221.186.184.68"
# IPSocket.getaddress 'www.ccc.de' #=> "2a00:1328:e102:ccc0::122"
def getaddress(s)
if valid?(s)
s
......
class IPAddr
# 32 bit mask for IPv4
IN4MASK = 0xffffffff
# 128 bit mask for IPv4
IN6MASK = 0xffffffffffffffffffffffffffffffff
# Formatstring for IPv6
IN6FORMAT = (["%.4x"] * 8).join(':')
# Returns the address family of this IP address.
......
protected
# Set +@addr+, the internal stored ip address, to given +addr+. The
# parameter +addr+ is validated using the first +family+ member,
# which is +Socket::AF_INET+ or +Socket::AF_INET6+.
def set(addr, *family)
case family[0] ? family[0] : @family
when Socket::AF_INET
......
return self
end
# Set current netmask to given mask.
def mask!(mask)
if mask.kind_of?(String)
if mask =~ /^\d+$/
    (1-1/1)