Class: By2::Models::Event
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- By2::Models::Event
- Defined in:
- lib/by2/models/event.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.in_date_range(start_date, end_date) ⇒ Object
19 20 21 22 23 |
# 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) ⇒ Object
15 16 17 |
# File 'lib/by2/models/event.rb', line 15 def self.on_date(date) where("cast(\"timestamp\" as date) = ?", date) end |
Instance Method Details
#dport ⇒ Object
33 34 35 |
# File 'lib/by2/models/event.rb', line 33 def dport tcphdr.try(:dport) || udphdr.try(:dport) end |
#ip_dst ⇒ Object
45 46 47 |
# File 'lib/by2/models/event.rb', line 45 def ip_dst iphdr.try(:ipaddr_dst) end |
#ip_src ⇒ Object
41 42 43 |
# File 'lib/by2/models/event.rb', line 41 def ip_src iphdr.try(:ipaddr_src) end |
#sport ⇒ Object
37 38 39 |
# File 'lib/by2/models/event.rb', line 37 def sport tcphdr.try(:sport) || udphdr.try(:sport) end |
#transport ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/by2/models/event.rb', line 25 def transport return "TCP" if tcphdr return "UCP" if udphdr return "ICMP" if icmphdr "UNKNOWN" end |