class By2::Models::Event

Public Class Methods

in_date_range(start_date, end_date) click to toggle source
# File lib/by2/models/event.rb, line 19
def self.in_date_range(start_date, end_date)
  query = where("cast(\"timestamp\" as date) >= ?", start_date)
  query = query.merge(where("cast(\"timestamp\" as date) <= ?", end_date)) if end_date
  query
end
on_date(date) click to toggle source
# File lib/by2/models/event.rb, line 15
def self.on_date(date)
  where("cast(\"timestamp\" as date) = ?", date)
end

Public Instance Methods

dport() click to toggle source
# File lib/by2/models/event.rb, line 33
def dport
  tcphdr.try(:dport) || udphdr.try(:dport)
end
ip_dst() click to toggle source
# File lib/by2/models/event.rb, line 45
def ip_dst
  iphdr.try(:ipaddr_dst)
end
ip_src() click to toggle source
# File lib/by2/models/event.rb, line 41
def ip_src
  iphdr.try(:ipaddr_src)
end
sport() click to toggle source
# File lib/by2/models/event.rb, line 37
def sport
  tcphdr.try(:sport) || udphdr.try(:sport)
end
transport() click to toggle source
# File lib/by2/models/event.rb, line 25
def transport
  return "TCP"  if tcphdr
  return "UCP"  if udphdr
  return "ICMP" if icmphdr

  "UNKNOWN"
end