Class: Mu::Xtractr::Host

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

Overview

xtractr.hosts

Defined Under Namespace

Classes: Test

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xtractr, address) ⇒ Host

:nodoc:



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

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

Instance Attribute Details

#addressObject (readonly)

Returns the address of this host.



25
26
27
# File 'lib/mu/xtractr/host.rb', line 25

def address
  @address
end

#xtractrObject (readonly)

:nodoc:



22
23
24
# File 'lib/mu/xtractr/host.rb', line 22

def xtractr
  @xtractr
end

Instance Method Details

#clients(q = nil) ⇒ Object

Use the host as a server and get a unique list of its clients.

xtractr.hosts(/192.168/).first.clients


34
35
36
37
# File 'lib/mu/xtractr/host.rb', line 34

def clients q=nil
    _q = role2q :server, 'flow', q
    Flows.new(xtractr, :q => _q).count('flow.src')
end

#flows(role = :any, q = nil) ⇒ Object

Return a flow iterator to iterate over the various flows that contain this host in the specified role.

host.flows :client


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

def flows role =:any, q=nil
    _q = role2q role, 'flow', q
    Flows.new(xtractr, :q => _q)
end

#inspectObject

:nodoc:



70
71
72
# File 'lib/mu/xtractr/host.rb', line 70

def inspect # :nodoc:
    "#<host:#{address}>"
end

#packets(role = :any, q = nil) ⇒ Object

Return a packet iterator to iterate over the various packets that contain this host in the specified role.

host.packets :server


65
66
67
68
# File 'lib/mu/xtractr/host.rb', line 65

def packets role =:any, q=nil
    _q = role2q role, 'pkt', q
    Packets.new(xtractr, :q => _q)
end

#servers(q = nil) ⇒ Object

Use the host as a client and get a unique list its servers.

xtractr.hosts(/192.168/).first.servers


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

def servers q=nil
    _q = role2q :client, 'flow', q
    Flows.new(xtractr, :q => _q).count('flow.dst')
end

#services(role = :any, q = nil) ⇒ Object

Get a unique list of the host’s services. role can be one of :any, :client or :server to specify the role.

host.services :server


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

def services role =:any, q=nil
    _q = role2q role, 'flow', q
    Flows.new(xtractr, :q => _q).count('flow.service')
end