lib/httpx/plugins/proxy/socks4.rb in httpx-0.9.0 vs lib/httpx/plugins/proxy/socks4.rb in httpx-0.10.0
- old
+ new
@@ -89,20 +89,22 @@
emit(:packet, packet)
end
end
module Packet
+ using(RegexpExtensions) unless Regexp.method_defined?(:match?)
+
module_function
def connect(parameters, uri)
packet = [VERSION, CONNECT, uri.port].pack("CCn")
begin
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 =~ /^socks4a?$/
+ if /^socks4a?$/.match?(parameters.uri.scheme)
# 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