Sha256: 4a93447bdaf0515f6a18424a2a4a5b5730264ac7993dfaf273ba4f0d3770e460

Contents?: true

Size: 365 Bytes

Versions: 5

Compression:

Stored size: 365 Bytes

Contents

# http://codesnippets.joyent.com/posts/show/7546
class IPAddr
  PRIVATE_RANGES = [
    IPAddr.new('127.0.0.1/32'),
    IPAddr.new('10.0.0.0/8'),
    IPAddr.new('172.16.0.0/12'),
    IPAddr.new('192.168.0.0/16')
  ]
  
  def private?
    return false unless self.ipv4?
    PRIVATE_RANGES.any? { |ipr| ipr.include? self }
  end

  def public?
    !private?
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
honeypot-0.0.6 lib/honeypot/ipaddr_ext.rb
honeypot-0.0.5 lib/honeypot/ipaddr_ext.rb
honeypot-0.0.4 lib/honeypot/ipaddr_ext.rb
honeypot-0.0.3 lib/honeypot/ipaddr_ext.rb
honeypot-0.0.2 lib/honeypot/ipaddr_ext.rb