Class: Mu::Xtractr::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/mu/xtractr/service.rb,
lib/mu/xtractr/test/tc_service.rb

Overview

others like ARP (all non-IP, layer2 services) are only available in packets.

Defined Under Namespace

Classes: Test

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xtractr, name) ⇒ Service

:nodoc:



33
34
35
36
# File 'lib/mu/xtractr/service.rb', line 33

def initialize xtractr, name # :nodoc:
    @xtractr = xtractr
    @name = name
end

Instance Attribute Details

#nameObject (readonly)

Return the name of the service



31
32
33
# File 'lib/mu/xtractr/service.rb', line 31

def name
  @name
end

#xtractrObject (readonly)

:nodoc:



28
29
30
# File 'lib/mu/xtractr/service.rb', line 28

def xtractr
  @xtractr
end

Instance Method Details

#clients(q = nil) ⇒ Object

Get a unique list of clients for this service

xtractr.service('http').clients


40
41
42
43
44
# File 'lib/mu/xtractr/service.rb', line 40

def clients q=nil
    _q = "flow.service:\"#{name}\""
    _q << " #{q}" if q
    Flows.new(xtractr, :q => _q).count('flow.src')
end

#flows(q = nil) ⇒ Object

Return an iterator that can yield all flows that have this service and matches the query

xtractr.service("DNS").flows("AAAA").each { |flow| ... }


66
67
68
69
70
# File 'lib/mu/xtractr/service.rb', line 66

def flows q=nil
    _q = "flow.service:\"#{name}\""
    _q << " #{q}" if q
    return Flows.new(xtractr, :q => _q)
end

#inspectObject

:nodoc:



72
73
74
# File 'lib/mu/xtractr/service.rb', line 72

def inspect # :nodoc:
    "#<service:#{name}>"
end

#packets(q = nil) ⇒ Object

Return an iterator that can yield all packets that have this service and matches the query

xtractr.service("DNS").packets("mu").each { |pkt| ... }


57
58
59
60
61
# File 'lib/mu/xtractr/service.rb', line 57

def packets q=nil
    _q = "pkt.service:\"#{name}\""
    _q << " #{q}" if q
    return Packets.new(xtractr, :q => _q)
end

#servers(q = nil) ⇒ Object

Get a unique list of servers for this service

xtractr.service('http').servers


48
49
50
51
52
# File 'lib/mu/xtractr/service.rb', line 48

def servers q=nil
    _q = "flow.service:\"#{name}\""
    _q << " #{q}" if q
    Flows.new(xtractr, :q => _q).count('flow.dst')
end