Class: By2::Client
Instance Method Summary collapse
-
#find_records(options = {}) ⇒ Object
payload: sid: 1, cid: 5 2149599422 => “128.32.72.190” 2954912804 => “176.32.100.36”.
-
#initialize(argv = []) ⇒ Client
constructor
A new instance of Client.
- #run ⇒ Object
Constructor Details
Instance Method Details
#find_records(options = {}) ⇒ Object
payload: sid: 1, cid: 5 2149599422 => “128.32.72.190” 2954912804 => “176.32.100.36”
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/by2/client.rb', line 17 def find_records( = {}) @opts = @opts.merge() tables = %w(iphdr tcphdr udphdr icmphdr payload) query = Event. includes(*tables). references(*tables). order("event.timestamp") query. merge(ip_src_or_dst). merge(port_src_or_dst). merge(port_src). merge(port_dst). merge(ip_src). merge(ip_dst). merge(date). merge(date_range) end |
#run ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/by2/client.rb', line 37 def run records = find_records unless @opts[:count] records.each { |r| $stdout.puts(terminal(r)) } end $stdout.puts(record_separator) $stdout.puts(record_count(records.count)) end |