Class: X509Sleuth::Scanner::Target
- Inherits:
-
Object
- Object
- X509Sleuth::Scanner::Target
- Defined in:
- lib/x509_sleuth/scanner/target.rb
Instance Attribute Summary collapse
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #hosts ⇒ Object
-
#initialize(target) ⇒ Target
constructor
A new instance of Target.
- #is_a_range? ⇒ Boolean
Constructor Details
#initialize(target) ⇒ Target
Returns a new instance of Target.
8 9 10 |
# File 'lib/x509_sleuth/scanner/target.rb', line 8 def initialize(target) @target = target end |
Instance Attribute Details
#target ⇒ Object (readonly)
Returns the value of attribute target.
6 7 8 |
# File 'lib/x509_sleuth/scanner/target.rb', line 6 def target @target end |
Instance Method Details
#hosts ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/x509_sleuth/scanner/target.rb', line 18 def hosts @hosts ||= if is_a_range? cidr = NetAddr::CIDR.create(target) cidr.enumerate.reject do |address| [cidr.network, cidr.broadcast].include?(address) end else [target] end end |
#is_a_range? ⇒ Boolean
12 13 14 15 16 |
# File 'lib/x509_sleuth/scanner/target.rb', line 12 def is_a_range? NetAddr::CIDR.create(target).size > 1 ? true : false rescue NetAddr::ValidationError false end |