File: errors.rb

package info (click to toggle)
ruby-em-socksify 0.3.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 168 kB
  • sloc: ruby: 256; sh: 20; makefile: 3
file content (43 lines) | stat: -rw-r--r-- 1,248 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
module EventMachine
  module Socksify

    class SOCKSError < Exception
      def self.define (message)
        Class.new(self) do
          def initialize
            super(message)
          end
        end
      end

      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')

      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
    end

  end

  module Connectify
    class CONNECTError < Exception
    end
  end
end