Class: Nmap::Port
- Inherits:
-
Object
- Object
- Nmap::Port
- Defined in:
- lib/nmap/port.rb
Instance Method Summary collapse
-
#initialize(node) ⇒ Port
constructor
Creates a new Port object.
-
#number ⇒ Integer
(also: #to_i)
The port number.
-
#protocol ⇒ Symbol
The protocol the port runs on.
-
#reason ⇒ String
The reason the port was discovered.
-
#scripts ⇒ Hash{String => String}
The output from the NSE scripts ran against the open port.
-
#service ⇒ String
The service the port provides.
-
#state ⇒ Symbol
The state of the port.
-
#to_s ⇒ String
Converts the port to a String.
Constructor Details
#initialize(node) ⇒ Port
Creates a new Port object.
10 11 12 |
# File 'lib/nmap/port.rb', line 10 def initialize(node) @node = node end |
Instance Method Details
#number ⇒ Integer Also known as: to_i
The port number.
30 31 32 |
# File 'lib/nmap/port.rb', line 30 def number @number ||= @node['portid'].to_i end |
#protocol ⇒ Symbol
The protocol the port runs on
20 21 22 |
# File 'lib/nmap/port.rb', line 20 def protocol @protocol ||= @node['protocol'].to_sym end |
#reason ⇒ String
The reason the port was discovered.
50 51 52 |
# File 'lib/nmap/port.rb', line 50 def reason @reason ||= @node.at('state/@reason').inner_text end |
#scripts ⇒ Hash{String => String}
The output from the NSE scripts ran against the open port.
74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/nmap/port.rb', line 74 def scripts unless @scripts @scripts = {} @node.xpath('script').each do |script| @scripts[script['id']] = script['output'] end end return @scripts end |
#service ⇒ String
The service the port provides.
60 61 62 63 64 |
# File 'lib/nmap/port.rb', line 60 def service @service ||= if (service = @node.at('service/@name')) service.inner_text end end |
#state ⇒ Symbol
The state of the port.
40 41 42 |
# File 'lib/nmap/port.rb', line 40 def state @state ||= @node.at('state/@state').inner_text.to_sym end |
#to_s ⇒ String
Converts the port to a String.
94 95 96 |
# File 'lib/nmap/port.rb', line 94 def to_s number.to_s end |