Class: Ronin::Recon::Values::Host

Inherits:
Ronin::Recon::Value show all
Defined in:
lib/ronin/recon/values/host.rb

Overview

Represents a host-name (ex: www.example.com).

Direct Known Subclasses

Domain, Mailserver, Nameserver

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Ronin::Recon::Value

#==, parse, #to_csv, #to_json

Constructor Details

#initialize(name) ⇒ Host

Initializes the host object.

Parameters:

  • name (String)

    The host name.



48
49
50
# File 'lib/ronin/recon/values/host.rb', line 48

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameString (readonly)

The host name.

Returns:

  • (String)


40
41
42
# File 'lib/ronin/recon/values/host.rb', line 40

def name
  @name
end

Class Method Details

.value_type:host

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.

Note:

This is used internally to map a recon value class to a printable type.

Returns the type or kind of recon value.

Returns:

  • (:host)


133
134
135
# File 'lib/ronin/recon/values/host.rb', line 133

def self.value_type
  :host
end

Instance Method Details

#===(other) ⇒ Boolean

Case equality method used for fuzzy matching.

Parameters:

  • other (Value)

    The other value to compare.

Returns:



77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/ronin/recon/values/host.rb', line 77

def ===(other)
  case other
  when Host
    @name == other.name
  when IP, Website, URL
    @name == other.host
  when EmailAddress
    other.address.end_with?("@#{@name}")
  else
    false
  end
end

#as_jsonHash{Symbol => Object}

Coerces the host value into JSON.

Returns:

  • (Hash{Symbol => Object})

    The Ruby Hash that will be converted into JSON.



118
119
120
# File 'lib/ronin/recon/values/host.rb', line 118

def as_json
  {type: :host, name: @name}
end

#eql?(other) ⇒ Boolean

Compares the value to another value.

Parameters:

  • other (Value)

    The other value to compare.

Returns:



62
63
64
# File 'lib/ronin/recon/values/host.rb', line 62

def eql?(other)
  self.class == other.class && @name == other.name
end

#hashInteger

The "hash" value of the host name.

Returns:

  • (Integer)

    The hash of the #name.



96
97
98
# File 'lib/ronin/recon/values/host.rb', line 96

def hash
  [self.class, @name].hash
end

#to_sString Also known as: to_str

Converts the IP object to a String.

Returns:

  • (String)

    The host name.



106
107
108
# File 'lib/ronin/recon/values/host.rb', line 106

def to_s
  @name.to_s
end