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
171 def authenticate(parameters)
172   parameters.authenticate
173 end
connect(uri)
[show source]
    # File lib/httpx/plugins/proxy/socks5.rb
175 def connect(uri)
176   packet = [VERSION, CONNECT, 0].pack("C*")
177   begin
178     ip = IPAddr.new(uri.host)
179 
180     ipcode = ip.ipv6? ? IPV6 : IPV4
181 
182     packet << [ipcode].pack("C") << ip.hton
183   rescue IPAddr::InvalidAddressError
184     packet << [DOMAIN, uri.host.bytesize, uri.host].pack("CCA*")
185   end
186   packet << [uri.port].pack("n")
187   packet
188 end
negotiate(parameters)
[show source]
    # File lib/httpx/plugins/proxy/socks5.rb
163 def negotiate(parameters)
164   methods = [NOAUTH]
165   methods << PASSWD if parameters.can_authenticate?
166   methods.unshift(methods.size)
167   methods.unshift(VERSION)
168   methods.pack("C*")
169 end