111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
# File 'lib/httpx/plugins/proxy/socks4.rb', line 111
def connect(parameters, uri)
packet = [VERSION, CONNECT, uri.port].pack("CCn")
case parameters.uri.scheme
when "socks4"
socks_host = uri.host
begin
ip = IPAddr.new(socks_host)
packet << ip.hton
rescue IPAddr::InvalidAddressError
socks_host = Resolv.getaddress(socks_host)
retry
end
packet << [parameters.username].pack("Z*")
when "socks4a"
packet << "\x0\x0\x0\x1" << [parameters.username].pack("Z*") << uri.host << "\x0"
end
packet
end
|