# 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
# 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(%r^(\d+)\.(\d+)\.(\d+)\.(\d+)$/) send_data "\x01" + matches.to_a[1 .. -1].map { |s| s.to_i }.pack('CCCC') elsif @socks_target_host =~ %r^[: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
# 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