module HTTPX::Plugins::Proxy::Socks5::Packet

  1. lib/httpx/plugins/proxy/socks5.rb

Methods

Public Instance

  1. authenticate
  2. connect
  3. negotiate

Public Instance methods

authenticate (parameters)
[show source]
    # File lib/httpx/plugins/proxy/socks5.rb
148 def authenticate(parameters)
149   user = parameters.username
150   pass = parameters.password
151   [0x01, user.bytesize, user, pass.bytesize, password].pack("CCA*CA*")
152 end
connect (uri)
[show source]
    # File lib/httpx/plugins/proxy/socks5.rb
154 def connect(uri)
155   packet = [VERSION, CONNECT, 0].pack("C*")
156   begin
157     ip = IPAddr.new(uri.host)
158     raise Error, "Socks4 connection to #{ip} not supported" unless ip.ipv4?
159 
160     packet << [IPV4, ip.to_i].pack("CN")
161   rescue IPAddr::InvalidAddressError
162     packet << [DOMAIN, uri.host.bytesize, uri.host].pack("CCA*")
163   end
164   packet << [uri.port].pack("n")
165   packet
166 end
negotiate (parameters)
[show source]
    # File lib/httpx/plugins/proxy/socks5.rb
140 def negotiate(parameters)
141   methods = [NOAUTH]
142   methods << PASSWD if parameters.authenticated?
143   methods.unshift(methods.size)
144   methods.unshift(VERSION)
145   methods.pack("C*")
146 end