lib/httpx/plugins/proxy/socks4.rb in httpx-0.6.3 vs lib/httpx/plugins/proxy/socks4.rb in httpx-0.6.4
- old
+ new
@@ -2,19 +2,20 @@
require "resolv"
require "ipaddr"
module HTTPX
+ Socks4Error = Class.new(Error)
module Plugins
module Proxy
module Socks4
VERSION = 4
CONNECT = 1
GRANTED = 90
PROTOCOLS = %w[socks4 socks4a].freeze
- Error = Class.new(Error)
+ Error = Socks4Error
module ConnectionMethods
private
def transition(nextstate)
@@ -98,10 +99,10 @@
ip = IPAddr.new(uri.host)
raise Error, "Socks4 connection to #{ip} not supported" unless ip.ipv4?
packet << [ip.to_i].pack("N")
rescue IPAddr::InvalidAddressError
- if parameters.uri.scheme == "socks4"
+ if parameters.uri.scheme =~ /^socks4a?$/
# resolv defaults to IPv4, and socks4 doesn't support IPv6 otherwise
ip = IPAddr.new(Resolv.getaddress(uri.host))
packet << [ip.to_i].pack("N")
else
packet << "\x0\x0\x0\x1" << "\x7\x0" << uri.host