Module: HTTPX::Plugins::Proxy::Socks5::Packet
- Defined in:
- lib/httpx/plugins/proxy/socks5.rb
Class Method Summary collapse
Class Method Details
.authenticate(parameters) ⇒ Object
165 166 167 168 169 |
# File 'lib/httpx/plugins/proxy/socks5.rb', line 165 def authenticate(parameters) user = parameters.username password = parameters.password [0x01, user.bytesize, user, password.bytesize, password].pack("CCA*CA*") end |
.connect(uri) ⇒ Object
171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/httpx/plugins/proxy/socks5.rb', line 171 def connect(uri) packet = [VERSION, CONNECT, 0].pack("C*") begin ip = IPAddr.new(uri.host) ipcode = ip.ipv6? ? IPV6 : IPV4 packet << [ipcode].pack("C") << ip.hton rescue IPAddr::InvalidAddressError packet << [DOMAIN, uri.host.bytesize, uri.host].pack("CCA*") end packet << [uri.port].pack("n") packet end |