Class: Masscan::Command::PortList Private
- Inherits:
-
CommandMapper::Types::List
- Object
- CommandMapper::Types::List
- Masscan::Command::PortList
- 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 the type for the -p,--ports
option.
Constant Summary collapse
- PORT_RANGE_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 for validating a port or port range.
PortRange::PORT_RANGE_REGEXP
- 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 port list String values.
/\A(?:(?:U:)?#{PORT_RANGE_REGEXP})(?:,(?:U:)?#{PORT_RANGE_REGEXP})*\z/
Instance Method Summary collapse
-
#format(value) ⇒ String
private
Formats a port list value into a String.
-
#initialize ⇒ PortList
constructor
private
Initializes the port list type.
-
#validate(value) ⇒ true, (false, String)
private
Validates a given value.
Constructor Details
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 a port list value into a String.
284 285 286 287 288 289 290 291 292 293 294 295 |
# File 'lib/masscan/command.rb', line 284 def format(value) case value when Range # format an individual port range @type.format(value) when String # pass strings directly through 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 a given value.
260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
# File 'lib/masscan/command.rb', line 260 def validate(value) case value when Range @type.validate(value) when String unless value =~ REGEXP return [false, "not a valid port list (#{value.inspect})"] end return true else super(value) end end |