29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/proxy_tester/cli/test.rb', line 29
def url(*urls)
ProxyTester.config = ProxyTester::Config.new(options[:config_file]) if options[:config_file]
ProxyTester.config.log_level = options[:log_level] if options[:log_level]
ProxyTester.config.debug_mode = options[:debug_mode] if options[:debug_mode]
ProxyTester.config.lock
ProxyTester.ui_logger.level = ProxyTester.config.log_level
ProxyTester.enable_debug_mode if ProxyTester.config.debug_mode
proxies = options[:proxy].collect { |p| HttpProxy.new(p) }
unless options[:user].blank?
user = User.new
user.name = options[:user]
while user.password.blank?
user.password = HighLine.new.ask("Enter password for proxy user \"#{user.name}\": ") { |q| q.echo = '*' }
end
puts ''
proxies.each { |p| p.use_user user }
end
output = options.fetch(:output, $stdout)
if output.kind_of? String
output = File.open(output, 'w')
else
output = $stdout
end
Actions::ClearEnvironment.new.run
proxies.each do |p|
ProxyTester.ui_logger.debug "Using proxy \"#{p.to_string}\""
ProxyTester.ui_logger.debug "Using user \"#{user.to_string}\""
action = Actions::FetchUrls.new( urls: urls,
timeout: options[:timeout],
count: options[:count],
proxy: p,
concurrent: options[:concurrent],
output: output,
)
action.run
end
end
|