Class: Masscan::Command::Target Private
- Inherits:
-
CommandMapper::Types::Str
- Object
- CommandMapper::Types::Str
- Masscan::Command::Target
- 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 --range
option and ips
argument(s).
Constant Summary collapse
- DECIMAL_OCTET_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 decimal octets (0-255).
/(?<=[^\d]|^)(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])(?=[^\d]|$)/
- IPV4_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 IPv4 addresses or CIDR ranges.
%r{#{DECIMAL_OCTET_REGEXP}(?:\.#{DECIMAL_OCTET_REGEXP}){3}(?:/\d{1,2})?}
- IPV6_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 IPv6 addresses or CIDR ranges.
%r{ (?:[0-9a-f]{1,4}:){6}#{IPV4_REGEXP}| (?:[0-9a-f]{1,4}:){5}[0-9a-f]{1,4}:#{IPV4_REGEXP}| (?:[0-9a-f]{1,4}:){5}:[0-9a-f]{1,4}:#{IPV4_REGEXP}| (?:[0-9a-f]{1,4}:){1,1}(?::[0-9a-f]{1,4}){1,4}:#{IPV4_REGEXP}| (?:[0-9a-f]{1,4}:){1,2}(?::[0-9a-f]{1,4}){1,3}:#{IPV4_REGEXP}| (?:[0-9a-f]{1,4}:){1,3}(?::[0-9a-f]{1,4}){1,2}:#{IPV4_REGEXP}| (?:[0-9a-f]{1,4}:){1,4}(?::[0-9a-f]{1,4}){1,1}:#{IPV4_REGEXP}| :(?::[0-9a-f]{1,4}){1,5}:#{IPV4_REGEXP}| (?:(?:[0-9a-f]{1,4}:){1,5}|:):#{IPV4_REGEXP}| (?:[0-9a-f]{1,4}:){1,1}(?::[0-9a-f]{1,4}){1,6}(?:/\d{1,3})?| (?:[0-9a-f]{1,4}:){1,2}(?::[0-9a-f]{1,4}){1,5}(?:/\d{1,3})?| (?:[0-9a-f]{1,4}:){1,3}(?::[0-9a-f]{1,4}){1,4}(?:/\d{1,3})?| (?:[0-9a-f]{1,4}:){1,4}(?::[0-9a-f]{1,4}){1,3}(?:/\d{1,3})?| (?:[0-9a-f]{1,4}:){1,5}(?::[0-9a-f]{1,4}){1,2}(?:/\d{1,3})?| (?:[0-9a-f]{1,4}:){1,6}(?::[0-9a-f]{1,4}){1,1}(?:/\d{1,3})?| [0-9a-f]{1,4}(?::[0-9a-f]{1,4}){7}(?:/\d{1,3})?| :(?::[0-9a-f]{1,4}){1,7}(?:/\d{1,3})?| (?:(?:[0-9a-f]{1,4}:){1,7}|:):(?:/\d{1,3})? }x
- 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 masscan target IPs or IP ranges.
/\A(?:#{IPV4_REGEXP}|#{IPV6_REGEXP})\z/
Instance Method Summary collapse
-
#validate(value) ⇒ true, (false, String)
private
Validates a IP or IP range target value.
Instance Method Details
#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 IP or IP range target value.
505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 |
# File 'lib/masscan/command.rb', line 505 def validate(value) case value when IPAddr return true else valid, = super(value) unless valid return [valid, ] end string = value.to_s unless string =~ REGEXP return [false, "invalid IP or IP range (#{value.inspect})"] end return true end end |