Module: Rex::HostCommunicationError

Included in:
BindFailed, ConnectionError
Defined in:
lib/rex/exceptions.rb

Overview

This exception is raised when there is some kind of error related to communication with a host.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#hostObject

Returns the value of attribute host.



174
175
176
# File 'lib/rex/exceptions.rb', line 174

def host
  @host
end

#portObject

Returns the value of attribute port.



174
175
176
# File 'lib/rex/exceptions.rb', line 174

def port
  @port
end

#reasonObject

Returns the value of attribute reason.



174
175
176
# File 'lib/rex/exceptions.rb', line 174

def reason
  @reason
end

Instance Method Details

#addr_to_sObject

This method returns a printable address and optional port associated with the host that triggered the exception.



158
159
160
161
162
163
164
165
166
# File 'lib/rex/exceptions.rb', line 158

def addr_to_s
  if host and port
    host.include?(':') ? "([#{host}]:#{port})" : "(#{host}:#{port})"
  elsif host
    "(#{host})"
  else
    ""
  end
end

#initialize(addr = nil, port = nil, reason: nil) ⇒ Object



148
149
150
151
152
# File 'lib/rex/exceptions.rb', line 148

def initialize(addr = nil, port = nil, reason: nil)
  @host = addr
  @port = port
  @reason = reason
end

#to_sObject



168
169
170
171
172
# File 'lib/rex/exceptions.rb', line 168

def to_s
  str = super
  str << " #{@reason}" if @reason
  str
end