Module: EventMachine::Socksify::SOCKS5

### Home Classes Methods

### In Files

- lib/em-socksify/socks5.rb

### Methods

- #socks_send_authentication
- #socks_send_connect_request
- #socks_send_handshake

### Class/Module Index

Quicksearch

- EventMachine
- EventMachine::Connectify
- EventMachine::Connectify::CONNECT
- EventMachine::Connectify::CONNECTError
- EventMachine::Socksify
- EventMachine::Socksify::SOCKS5
- EventMachine::Socksify::SOCKSError
- Base64

No matching classes.

# EventMachine::Socksify::SOCKS5

### Public Instance Methods

socks_send_authentication() click to toggle source

    # File lib/em-socksify/socks5.rb, line 33
    def socks_send_authentication
      @socks_state = :authenticating

      send_data [5,
                 @socks_username.length, @socks_username,
                 @socks_password.length, @socks_password
                 ].pack('CCA*CA*')
    end

socks_send_connect_request() click to toggle source

    # File lib/em-socksify/socks5.rb, line 15
    def socks_send_connect_request
      @socks_state = :connecting

      send_data [5, 1, 0].pack('CCC')

      if matches = @socks_target_host.match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/)
        send_data "\x01" + matches.to_a[1 .. -1].map { |s| s.to_i }.pack('CCCC')

      elsif @socks_target_host =~ /^[:0-9a-f]+$/
        raise SOCKSError, 'TCP/IPv6 over SOCKS is not yet supported (inet_pton missing in Ruby & not supported by Tor)'

      else
        send_data [3, @socks_target_host.size, @socks_target_host].pack('CCA*')
      end

      send_data [@socks_target_port].pack('n')
    end

socks_send_handshake() click to toggle source

    # File lib/em-socksify/socks5.rb, line 5
    def socks_send_handshake
      # Method Negotiation as described on
      # http://www.faqs.org/rfcs/rfc1928.html Section 3
      @socks_state = :method_negotiation

      socks_methods.tap do |methods|
        send_data [5, methods.size].pack('CC') + methods.pack('C*')
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.