Module: HTTPX::Plugins::Proxy::Socks5::Packet
- Defined in:
- lib/httpx/plugins/proxy/socks5.rb
Class Method Summary collapse
Class Method Details
.authenticate(parameters) ⇒ Object
139 140 141 142 143 |
# File 'lib/httpx/plugins/proxy/socks5.rb', line 139 def authenticate(parameters) user = parameters.username pass = parameters.password [0x01, user.bytesize, user, pass.bytesize, password].pack("CCA*CA*") end |
.connect(uri) ⇒ Object
145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/httpx/plugins/proxy/socks5.rb', line 145 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 |