Class: IPAddr

Inherits:
Object
  • Object
show all
Defined in:
lib/honeypot/ipaddr_ext.rb

Overview

Constant Summary collapse

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')
]

Instance Method Summary collapse

Instance Method Details

#private?Boolean

Returns:

  • (Boolean)


10
11
12
13
# File 'lib/honeypot/ipaddr_ext.rb', line 10

def private?
  return false unless self.ipv4?
  PRIVATE_RANGES.any? { |ipr| ipr.include? self }
end

#public?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/honeypot/ipaddr_ext.rb', line 15

def public?
  !private?
end