Class: Poke::Checks::Blacklist::FreeBlacklistCheck

Inherits:
Poke::Check
  • Object
show all
Defined in:
lib/poke/checks/blacklist/free_blacklist_check.rb

Instance Attribute Summary

Attributes inherited from Poke::Check

#name

Instance Method Summary collapse

Constructor Details

#initialize(ip) ⇒ FreeBlacklistCheck

Returns a new instance of FreeBlacklistCheck.



17
18
19
20
21
# File 'lib/poke/checks/blacklist/free_blacklist_check.rb', line 17

def initialize(ip)
  name = "Blacklist of #{ip} (postmaster free)"
  @ip = ip
  super name
end

Instance Method Details

#runObject

Run the check



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/poke/checks/blacklist/free_blacklist_check.rb', line 24

def run
  html = URI.parse("http://postmaster.free.fr/showipstate.pl?ip=#{@ip}").read
  doc = Nokogiri::HTML(html)
  nodes = doc.search("//div[@class='level1']/font")
  message = nodes.at(0).inner_text

  if message =~ /blacklist/
    return :error, message
  end

  return :ok, message
end