From 799b2e04f758571d34b3ce0addddba5de6df172d Mon Sep 17 00:00:00 2001 From: Snow Helsing Date: Sun, 8 May 2016 19:23:22 +0800 Subject: [PATCH] NEW: support specify socket class in Proxy#open --- lib/proxifier/proxy.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/proxifier/proxy.rb b/lib/proxifier/proxy.rb index 0bbb1b6..ea9794b 100644 --- a/lib/proxifier/proxy.rb +++ b/lib/proxifier/proxy.rb @@ -20,10 +20,11 @@ def initialize(url, options = {}) @url, @options = url, options end - def open(host, port, local_host = nil, local_port = nil) - return TCPSocket.new(host, port, local_host, local_port) unless proxify?(host) + def open(host, port, local_host = nil, local_port = nil, socket_klass = nil) + socket_klass ||= TCPSocket + return socket_klass.new(host, port, local_host, local_port) unless proxify?(host) - socket = TCPSocket.new(self.host, self.port, local_host, local_port) + socket = socket_klass.new(self.host, self.port, local_host, local_port) begin proxify(socket, host, port)