Class: Threatinator::Amqp::Rcvr::FQDNTable
- Defined in:
- lib/threatinator/amqp/rcvr/table.rb
Instance Method Summary collapse
Methods inherited from Table
Constructor Details
This class inherits a constructor from Threatinator::Amqp::Rcvr::Table
Instance Method Details
#subscribe ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/threatinator/amqp/rcvr/table.rb', line 33 def subscribe dnslist = [] puts "#[threatinator-ampq-rcvr] #{self.class } - amqp subscribing" if Threatinator::Amqp::Rcvr::Settings.verbose @q.subscribe(:block => true) do |delivery_info, properties, body| # Extract FQDN dataset = JSON.parse(body) dataset["urls"].each do |v| host = URI.parse(v).host #puts host if (/[A-Za-z]/.match(host) && !(/[ ]/.match(host))) dnslist << host begin @db.insert(dataset["import_time"], host, dataset["feed_provider"], dataset["feed_name"] ) rescue SQLite3::ConstraintException print "-" if Threatinator::Amqp::Rcvr::Settings.verbose end end end dataset["fqdns"].each do |v| dnslist << 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 |