Module: HTTPX::Plugins::Proxy::Socks5::Packet
- Defined in:
- lib/httpx/plugins/proxy/socks5.rb
Class Method Summary collapse
Class Method Details
.authenticate(parameters) ⇒ Object
148 149 150 151 152 |
# File 'lib/httpx/plugins/proxy/socks5.rb', line 148 def authenticate(parameters) user = parameters.username pass = parameters.password [0x01, user.bytesize, user, pass.bytesize, password].pack("CCA*CA*") end |
.connect(uri) ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/httpx/plugins/proxy/socks5.rb', line 154 def connect(uri) packet = [VERSION, CONNECT, 0].pack("C*") begin ip = IPAddr.new(uri.host) raise Error, "Socks4 connection to #{ip} not supported" unless ip.ipv4? packet << [IPV4, ip.to_i].pack("CN") rescue IPAddr::InvalidAddressError packet << [DOMAIN, uri.host.bytesize, uri.host].pack("CCA*") end packet << [uri.port].pack("n") packet end |