Class: Masscan::Command::PortRange Private
- 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 range.
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 to validate either a port or a port range.
/#{PORT_REGEXP}-#{PORT_REGEXP}|#{PORT_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 to validate either a port or a port range.
/\A#{PORT_RANGE_REGEXP}\z/
Constants inherited from Port
Masscan::Command::Port::PORT_REGEXP
Instance Method Summary collapse
-
#format(value) ⇒ String
private
Formats the given port or port range value.
-
#validate(value) ⇒ true, (false, String)
private
Validates the given port or port range value.
Methods inherited from Port
Constructor Details
This class inherits a constructor from Masscan::Command::Port
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 or port range value.
219 220 221 222 223 224 225 226 |
# File 'lib/masscan/command.rb', line 219 def format(value) case value when Range "#{value.begin}-#{value.end}" 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 port or port range value.
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/masscan/command.rb', line 183 def validate(value) case value when Range valid, = super(value.begin) unless valid return [valid, ] end valid, = super(value.end) unless valid return [valid, ] end return true when String unless value =~ REGEXP return [false, "must be a valid port range or port number (#{value.inspect})"] end return true else super(value) end end |