Class: Masscan::Command::Port Private
- Inherits:
-
CommandMapper::Types::Num
- Object
- CommandMapper::Types::Num
- Masscan::Command::Port
- Defined in:
- lib/masscan/command.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Represents a port number.
Direct Known Subclasses
Constant Summary collapse
- PORT_REGEXP =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Regular expression that validates a port number.
/[1-9][0-9]{0,3}|[1-5][0-9][0-9][0-9][0-9]|6[0-4][0-9][0-9][0-9]|65[0-4][0-9][0-9]|655[0-2][0-9]|6553[0-5]/
- REGEXP =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Regular expression that validates either a port number or service name.
/\A#{PORT_REGEXP}\z/
Instance Method Summary collapse
-
#format(value) ⇒ String
private
Formats the given port number.
-
#initialize ⇒ Port
constructor
private
Initializes the port type.
-
#validate(value) ⇒ true, (false, String)
private
Validates the given value.
Constructor Details
#initialize ⇒ Port
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes the port type.
111 112 113 |
# File 'lib/masscan/command.rb', line 111 def initialize super(range: 1..65535) end |
Instance Method Details
#format(value) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Formats the given port number.
147 148 149 150 151 152 153 154 |
# File 'lib/masscan/command.rb', line 147 def format(value) case value when String value else super(value) end end |
#validate(value) ⇒ true, (false, String)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Validates the given value.
125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/masscan/command.rb', line 125 def validate(value) case value when String unless value =~ REGEXP return [false, "must be a valid port number (#{value.inspect})"] end return true else super(value) end end |