Sha256: ec1bdaaee1c3eea8adf9871e5dd4e7c830b9f67f1367a5240076d2598d37d14e
Contents?: true
Size: 1.77 KB
Versions: 5
Compression:
Stored size: 1.77 KB
Contents
module Nmap class Port # # Creates a new Port object. # # @param [Nokogiri::XML::Element] node # The XML `port` element. # def initialize(node) @node = node end # # The protocol the port runs on # # @return [Symbol] # The protocol of the port. # def protocol @protocol ||= @node['protocol'].to_sym end # # The port number. # # @return [Integer] # The number of the port. # def number @number ||= @node['portid'].to_i end # # The state of the port. # # @return [Symbol] # The state of the port (`:open`, `:filtered` or `:closed`). # def state @state ||= @node.at('state/@state').inner_text.to_sym end # # The reason the port was discovered. # # @return [String] # How the port was discovered. # def reason @reason ||= @node.at('state/@reason').inner_text end # # The service the port provides. # # @return [String] # The service detected on the port. # def service @service ||= if (service = @node.at('service/@name')) service.inner_text end end # # The output from the NSE scripts ran against the open port. # # @return [Hash{String => String}] # The NSE script names and output. # # @since 0.3.0 # def scripts unless @scripts @scripts = {} @node.xpath('script').each do |script| @scripts[script['id']] = script['output'] end end return @scripts end alias to_i number # # Converts the port to a String. # # @return [String] # The port number. # def to_s number.to_s end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
ruby-nmap-0.5.1 | lib/nmap/port.rb |
ruby-nmap-0.5.0 | lib/nmap/port.rb |
ruby-nmap-0.4.1 | lib/nmap/port.rb |
ruby-nmap-0.4.0 | lib/nmap/port.rb |
ruby-nmap-0.3.0 | lib/nmap/port.rb |