class RblMcafee::Zone

Constants

MC_AFEE_RBL_LISTED_REGEX

@see kc.mcafee.com/corporate/index?page=content&id=KB53783 If the reply is in the format 127.0.0.XXX, the host is listed in the McAfee RBL (@see below)

PBL
SBL
XBL

Attributes

ip[R]

Public Class Methods

new(ip) click to toggle source
# File lib/rbl_mcafee/zone.rb, line 13
def initialize(ip)
  raise ArgumentError, 'Invalid IP' unless RblMcafee::Ip.new(ip).valid?

  @ip = ip
end

Public Instance Methods

pbl?() click to toggle source
# File lib/rbl_mcafee/zone.rb, line 19
def pbl?
  zone == PBL
end
sbl?() click to toggle source
# File lib/rbl_mcafee/zone.rb, line 23
def sbl?
  zone == SBL
end
xbl?() click to toggle source
# File lib/rbl_mcafee/zone.rb, line 27
def xbl?
  zone == XBL
end

Private Instance Methods

extract_zone(resolved_ip) click to toggle source

@see www.spamhaus.org/faq/section/DNSBL%20Usage#202

DNSBL | Returns | Contains ——---------------————————————————— SBL | 127.0.0.2-3 | Static UBE sources, verified spam services

|               | (hosting or support) and ROKSO spammers

XBL | 127.0.0.4-7 | Illegal 3rd party exploits, including proxies,

\               | worms and trojan exploits

PBL | 127.0.0.10-11 | IP ranges which should not be delivering

|               | unauthenticated SMTP email.
# File lib/rbl_mcafee/zone.rb, line 69
def extract_zone(resolved_ip)
  return nil if resolved_ip.nil?
  return nil unless resolved_ip.match(MC_AFEE_RBL_LISTED_REGEX)

  case resolved_ip.split('.').last.to_i
  when 2..3   then SBL
  when 4..7   then XBL
  when 10..11 then PBL
  else nil
  end
end
resolved_ip() click to toggle source

Lookup the IP address on “cidr.bl.mcafee.com”

# File lib/rbl_mcafee/zone.rb, line 41
def resolved_ip
  return @resolved_ip if defined? @resolved_ip

  reversed_ip = ip.split('.').reverse.join('.')
  @resolved_ip = Resolv::getaddress("#{reversed_ip}.cidr.bl.mcafee.com")

  rescue Resolv::ResolvError
    @resolved_ip = nil
  rescue Resolv::ResolvTimeout
    raise RblMcafee::Timeout
end
zone() click to toggle source
# File lib/rbl_mcafee/zone.rb, line 34
def zone
  return @zone if defined? @zone

  @zone = extract_zone(resolved_ip)
end