Class: Nmap::XML::Port
Overview
Wraps a port
XML element.
Instance Method Summary collapse
-
#initialize(node) ⇒ Port
constructor
Creates a new Port object.
-
#inspect ⇒ String
Inspects the port.
-
#number ⇒ Integer
(also: #to_i)
The port number.
-
#protocol ⇒ Symbol
The protocol the port runs on.
-
#reason ⇒ String
The reason the port was discovered.
-
#reason_ttl ⇒ Integer
The reason TTL.
-
#service ⇒ Service
The fingerprinted service of the port.
-
#state ⇒ Symbol
The state of the port.
-
#to_s ⇒ String
Converts the port to a String.
Methods included from Scripts
Constructor Details
#initialize(node) ⇒ Port
Creates a new Port object.
23 24 25 |
# File 'lib/nmap/xml/port.rb', line 23 def initialize(node) @node = node end |
Instance Method Details
#inspect ⇒ String
Inspects the port.
110 111 112 |
# File 'lib/nmap/xml/port.rb', line 110 def inspect "#<#{self.class}: #{self}>" end |
#number ⇒ Integer Also known as: to_i
The port number.
43 44 45 |
# File 'lib/nmap/xml/port.rb', line 43 def number @number ||= @node['portid'].to_i end |
#protocol ⇒ Symbol
The protocol the port runs on
33 34 35 |
# File 'lib/nmap/xml/port.rb', line 33 def protocol @protocol ||= @node['protocol'].to_sym end |
#reason ⇒ String
The reason the port was discovered.
63 64 65 |
# File 'lib/nmap/xml/port.rb', line 63 def reason @reason ||= @node.at_xpath('state/@reason').inner_text end |
#reason_ttl ⇒ Integer
The reason TTL.
74 75 76 |
# File 'lib/nmap/xml/port.rb', line 74 def reason_ttl @reason ||= @node.at_xpath('state/@reason_ttl').inner_text.to_i end |
#service ⇒ Service
The fingerprinted service of the port.
86 87 88 89 90 |
# File 'lib/nmap/xml/port.rb', line 86 def service @service_info ||= if (service = @node.at_xpath('service')) Service.new(service) end end |
#state ⇒ Symbol
The state of the port.
53 54 55 |
# File 'lib/nmap/xml/port.rb', line 53 def state @state ||= @node.at_xpath('state/@state').inner_text.to_sym end |
#to_s ⇒ String
Converts the port to a String.
100 101 102 |
# File 'lib/nmap/xml/port.rb', line 100 def to_s number.to_s end |