lib/httpx/plugins/proxy/socks5.rb in httpx-0.6.3 vs lib/httpx/plugins/proxy/socks5.rb in httpx-0.6.4
- old
+ new
@@ -1,8 +1,9 @@
# frozen_string_literal: true
module HTTPX
+ Socks5Error = Class.new(Error)
module Plugins
module Proxy
module Socks5
VERSION = 5
NOAUTH = 0
@@ -12,11 +13,11 @@
IPV4 = 1
DOMAIN = 3
IPV6 = 4
SUCCESS = 0
- Error = Class.new(Error)
+ Error = Socks5Error
module ConnectionMethods
def call
super
@@ -75,19 +76,18 @@
version, method = packet.unpack("CC")
__socks5_check_version(version)
case method
when PASSWD
transition(:authenticating)
- return
+ nil
when NONE
__on_socks5_error("no supported authorization methods")
else
transition(:negotiating)
end
when :authenticating
- version, status = packet.unpack("CC")
- __socks5_check_version(version)
+ _, status = packet.unpack("CC")
return transition(:negotiating) if status == SUCCESS
__on_socks5_error("socks authentication error: #{status}")
when :negotiating
version, reply, = packet.unpack("CC")
@@ -145,11 +145,11 @@
methods.pack("C*")
end
def authenticate(parameters)
user = parameters.username
- pass = parameters.password
- [0x01, user.bytesize, user, pass.bytesize, password].pack("CCA*CA*")
+ password = parameters.password
+ [0x01, user.bytesize, user, password.bytesize, password].pack("CCA*CA*")
end
def connect(uri)
packet = [VERSION, CONNECT, 0].pack("C*")
begin