Class: Threatinator::Amqp::Rcvr::IPTable

Inherits:
Table
  • Object
show all
Defined in:
lib/threatinator/amqp/rcvr/table.rb

Instance Method Summary collapse

Methods inherited from Table

#close, #initialize

Constructor Details

This class inherits a constructor from Threatinator::Amqp::Rcvr::Table

Instance Method Details

#subscribeObject



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/threatinator/amqp/rcvr/table.rb', line 67

def subscribe

  list = []
  puts "#[threatinator-ampq-rcvr] #{self.class } - amqp subscribing" if Threatinator::Amqp::Rcvr::Settings.verbose
  @q.subscribe(:block => true) do |delivery_info, properties, body|
    dataset = JSON.parse(body)
    dataset["ipv4s"].each do |v|
      list << v
      begin
        @db.insert(dataset["import_time"], v, dataset["feed_provider"], dataset["feed_name"])
      rescue SQLite3::ConstraintException
        print "-" if Threatinator::Amqp::Rcvr::Settings.verbose
      end
    end
    print "." if Threatinator::Amqp::Rcvr::Settings.verbose
  end

end