Module: PatronusFati::MessageProcessor::Ssid

Includes:
PatronusFati::MessageProcessor
Defined in:
lib/patronus_fati/message_processor/ssid.rb

Class Method Summary collapse

Methods included from PatronusFati::MessageProcessor

cleanup_models, close_inactive_connections, handle, ignored_types, offline_access_points, offline_clients, periodic_flush

Methods included from FactoryBase

#class_to_name, #factory, #ignored_types, #included, #registered_factories

Class Method Details

.process(obj) ⇒ void



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/patronus_fati/message_processor/ssid.rb', line 4

def self.process(obj)
  # Ignore the initial flood of cached data and any objects that would have
  # already expired
  return unless PatronusFati.past_initial_flood? &&
    obj[:lasttime] >= PatronusFati::DataModels::Ssid.current_expiration_threshold

  if %w(beacon probe_response).include?(obj[:type])
    ssid_info = ssid_data(obj.attributes)

    access_point = PatronusFati::DataModels::AccessPoint[obj[:mac]]
    access_point.track_ssid(ssid_info)
    access_point.presence.mark_visible
    access_point.announce_changes
  elsif obj[:type] == 'probe_request' && !obj[:ssid].empty?
    client = PatronusFati::DataModels::Client[obj[:mac]]
    client.presence.mark_visible
    client.track_probe(obj[:ssid])
    client.announce_changes
  end

  nil
end

.ssid_data(attrs) ⇒ void (protected)



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/patronus_fati/message_processor/ssid.rb', line 29

def self.ssid_data(attrs)
  crypt_set = attrs[:cryptset].map(&:to_s)
  crypt_set << 'WPS' if %w(WPS_CONFIGURED WPS_LOCKED).include?(attrs[:wps])

  {
    beacon_info: attrs[:beaconinfo],
    beacon_rate: attrs[:beaconrate],
    cloaked:     attrs[:cloaked],
    crypt_set:   crypt_set,
    essid:       attrs[:ssid],
    max_rate:    attrs[:maxrate],
  }.reject { |_, v| v.nil? }
end