Class: NetCrawl::Peer

Inherits:
Object
  • Object
show all
Defined in:
lib/netcrawl/peer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePeer

Returns a new instance of Peer.



4
5
6
7
8
9
10
11
12
# File 'lib/netcrawl/peer.rb', line 4

def initialize
  @ip       = nil  # Best guess of system IP
  @name     = nil  # Reverse of said IP
  @raw_ip   = nil  # IP as seen in polling
  @raw_name = nil  # Name as seen in polling
  @src      = nil  # SRC/local interface
  @dst      = nil  # DSR/remote interface
  @oid      = {}   # Hash of oids collected
end

Instance Attribute Details

#dstObject

Returns the value of attribute dst.



3
4
5
# File 'lib/netcrawl/peer.rb', line 3

def dst
  @dst
end

#ipObject

Returns the value of attribute ip.



3
4
5
# File 'lib/netcrawl/peer.rb', line 3

def ip
  @ip
end

#oidObject

Returns the value of attribute oid.



3
4
5
# File 'lib/netcrawl/peer.rb', line 3

def oid
  @oid
end

#raw_ipObject

Returns the value of attribute raw_ip.



3
4
5
# File 'lib/netcrawl/peer.rb', line 3

def raw_ip
  @raw_ip
end

#raw_nameObject

Returns the value of attribute raw_name.



3
4
5
# File 'lib/netcrawl/peer.rb', line 3

def raw_name
  @raw_name
end

#srcObject

Returns the value of attribute src.



3
4
5
# File 'lib/netcrawl/peer.rb', line 3

def src
  @src
end

Instance Method Details

#nameObject



13
14
15
# File 'lib/netcrawl/peer.rb', line 13

def name
  @name ||= DNS.getname @ip
end

#to_hashObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/netcrawl/peer.rb', line 16

def to_hash
  {
    'ip'   => ip.to_s,
    'name' => name.to_s,
    'interface' => {
       'source' => src.to_s,
       'destination' => dst.to_s,
    },
    'raw' => {
      'ip'   => raw_ip.to_s,
      'name' => raw_name.to_s,
    },
  }
end