module PatronusFati::MessageProcessor
Public Class Methods
cleanup_models()
click to toggle source
# File lib/patronus_fati/message_processor.rb, line 5 def self.cleanup_models @next_cleanup ||= Time.now.to_i + 60 if @next_cleanup <= Time.now.to_i @next_cleanup = Time.now.to_i + 60 close_inactive_connections offline_access_points offline_clients end end
close_inactive_connections()
click to toggle source
# File lib/patronus_fati/message_processor.rb, line 18 def self.close_inactive_connections DataModels::Connection.instances.each do |_, connection| connection.announce_changes end DataModels::Connection.instances.reject! { |_, conn| conn.presence.dead? } end
handle(message_obj)
click to toggle source
# File lib/patronus_fati/message_processor.rb, line 44 def self.handle(message_obj) if !PatronusFati.past_initial_flood? && @last_msg_received && (Time.now.to_f - @last_msg_received) >= 0.8 PatronusFati.past_initial_flood! end @last_msg_received = Time.now.to_f periodic_flush result = factory(class_to_name(message_obj), message_obj) cleanup_models result rescue => e PatronusFati.logger.error('Error processing the following message object:') PatronusFati.logger.error(message_obj.inspect) PatronusFati.logger.error('%s: %s' % [e.class, e.message]) e.backtrace.each do |l| PatronusFati.logger.error(l) end # Need to ensure our backtrace doesn't get sent to kismet nil end
ignored_types()
click to toggle source
# File lib/patronus_fati/message_processor.rb, line 66 def self.ignored_types [:ack, :battery, :bssidsrc, :channel, :clisrc, :gps, :info, :kismet, :plugin, :source, :status, :time] end
offline_access_points()
click to toggle source
# File lib/patronus_fati/message_processor.rb, line 26 def self.offline_access_points DataModels::AccessPoint.instances.each do |bssid, access_point| access_point.cleanup_ssids access_point.announce_changes end DataModels::AccessPoint.instances.reject! { |_, ap| ap.presence.dead? } end
offline_clients()
click to toggle source
# File lib/patronus_fati/message_processor.rb, line 35 def self.offline_clients DataModels::Client.instances.each do |_, client| client.cleanup_probes client.announce_changes end DataModels::Client.instances.reject! { |_, ap| ap.presence.dead? } end
periodic_flush()
click to toggle source
# File lib/patronus_fati/message_processor.rb, line 71 def self.periodic_flush @next_sync ||= Time.now.to_i + 300 if @next_sync <= Time.now.to_i # Add a variability of +/- half an hour within a day @next_sync = Time.now.to_i + 84600 + rand(3600) access_points = [] clients = [] PatronusFati::DataModels::AccessPoint.instances.each do |bssid, access_point| next unless access_point.sync_flag?(:syncedOnline) PatronusFati.event_handler.event(:access_point, :sync, access_point.full_state, access_point.diagnostic_data) access_points << bssid end PatronusFati::DataModels::Client.instances.each do |mac, client| next unless client.sync_flag?(:syncedOnline) PatronusFati.event_handler.event(:client, :sync, client.full_state, client.diagnostic_data) clients << mac end all_online = { access_points: access_points, clients: clients } PatronusFati.event_handler.event(:both, :sync, all_online) end end