Exception: EventMachine::Socksify::SOCKSError

Inherits:
Exception
  • Object
show all
Defined in:
lib/em-socksify/errors.rb

Constant Summary collapse

ServerFailure =
define('general SOCKS server failure')
NotAllowed =
define('connection not allowed by ruleset')
NetworkUnreachable =
define('Network unreachable')
HostUnreachable =
define('Host unreachable')
ConnectionRefused =
define('Connection refused')
TTLExpired =
define('TTL expired')
CommandNotSupported =
define('Command not supported')
AddressTypeNotSupported =
define('Address type not supported')

Class Method Summary collapse

Class Method Details

.define(message) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/em-socksify/errors.rb', line 5

def self.define(message)
  Class.new(self) do
    def initialize
      super(message)
    end
  end
end

.for_response_code(code) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/em-socksify/errors.rb', line 22

def self.for_response_code(code)
  case code.is_a?(String) ? code.ord : code
  when 1 then ServerFailure
  when 2 then NotAllowed
  when 3 then NetworkUnreachable
  when 4 then HostUnreachable
  when 5 then ConnectionRefused
  when 6 then TTLExpired
  when 7 then CommandNotSupported
  when 8 then AddressTypeNotSupported
  else self
  end
end