proxypoke 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/bin/proxypoke +53 -0
- data/lib/proxypoke.rb +30 -0
- metadata +45 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 6bcfdb353da832f2c35c0077d975d93d616b4a2de6f11aab45bba230e08046f4
|
|
4
|
+
data.tar.gz: 25f095917480f0397e0c25a049b7377123ab99f5b090e4f9068db8d3966dd5df
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 0d3d1c6ec7579a355f26cc54bd2906cc94f9839550f1a6243f9da7992b59d9a4399d1029ead19929a0873d08e36052d6e5c6b5d045e290aec99acfafba1a8911
|
|
7
|
+
data.tar.gz: 6f829549fc74d76f5e95512dac096e28b5a3ef5512b64bfe632986b9d4d1df9c7613c07144cd7c7d3980a617f6d5a7651c07a5f7821f5d50c47a5db4b3865de4
|
data/bin/proxypoke
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "optparse"
|
|
4
|
+
|
|
5
|
+
require "proxypoke"
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
options = {
|
|
10
|
+
proxy_host: "localhost",
|
|
11
|
+
proxy_port: 3128,
|
|
12
|
+
read_timeout: 3,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
options_parser = OptionParser.new do |parser|
|
|
17
|
+
parser.banner = "Usage: proxypass [options]"
|
|
18
|
+
|
|
19
|
+
parser.on("-u", "--url URL", "Test URL to query. Required.") do |v|
|
|
20
|
+
options[:url] = v
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
parser.on("-o", "--proxy-host HOST", "Proxy hostname or IP address. Defaults to 'localhost'.") do |v|
|
|
24
|
+
options[:proxy_host] = v
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
parser.on("-p", "--proxy-port PORT", Integer, "Port to connect to on the proxy host. Defaults to 3128.") do |v|
|
|
28
|
+
options[:proxy_port] = v
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
parser.on("-t", "--timeout", Float, "Request timeout value. Defaults to 3 seconds") do |v|
|
|
32
|
+
options[:read_timeout] = v
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
parser.on("-h", "--help", "Prints this help.") do
|
|
36
|
+
puts parser
|
|
37
|
+
exit
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
options_parser.parse!
|
|
43
|
+
|
|
44
|
+
if not options.keys.include? :url
|
|
45
|
+
puts options_parser.help
|
|
46
|
+
exit(false)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
result, message = ProxyPoke.poke(options[:url], options[:proxy_host], options[:proxy_port], options[:read_timeout])
|
|
50
|
+
|
|
51
|
+
puts "#{result}: #{message}"
|
|
52
|
+
result == "Success" ? exit : exit(1)
|
|
53
|
+
|
data/lib/proxypoke.rb
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require "net/http"
|
|
2
|
+
|
|
3
|
+
module ProxyPoke
|
|
4
|
+
def self.poke(url, proxy_host, proxy_port, read_timeout)
|
|
5
|
+
uri = URI(url)
|
|
6
|
+
|
|
7
|
+
client = Net::HTTP.new(
|
|
8
|
+
address = uri.host,
|
|
9
|
+
port = uri.port,
|
|
10
|
+
p_addr = proxy_host,
|
|
11
|
+
p_port = proxy_port,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
client.use_ssl = uri.scheme == "https" ? true : false
|
|
15
|
+
client.read_timeout = read_timeout
|
|
16
|
+
|
|
17
|
+
begin
|
|
18
|
+
response = client.get(url)
|
|
19
|
+
result, message = "Success", "#{proxy_host}:#{proxy_port} is working"
|
|
20
|
+
rescue Net::ReadTimeout
|
|
21
|
+
result, message = "Error", "connection timed out after #{client.read_timeout} seconds"
|
|
22
|
+
rescue Errno::ECONNREFUSED
|
|
23
|
+
result, message = "Error", "could not connect to proxy #{proxy_host} on port #{proxy_port}"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
return result, message
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: proxypoke
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- David Jennings
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2024-10-06 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description:
|
|
14
|
+
email: david@chillidoor.com
|
|
15
|
+
executables:
|
|
16
|
+
- proxypoke
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- bin/proxypoke
|
|
21
|
+
- lib/proxypoke.rb
|
|
22
|
+
homepage: https://github.com/chillidoor/proxypoke/
|
|
23
|
+
licenses:
|
|
24
|
+
- MIT
|
|
25
|
+
metadata: {}
|
|
26
|
+
post_install_message:
|
|
27
|
+
rdoc_options: []
|
|
28
|
+
require_paths:
|
|
29
|
+
- lib
|
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
31
|
+
requirements:
|
|
32
|
+
- - ">="
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: '2.7'
|
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
40
|
+
requirements: []
|
|
41
|
+
rubygems_version: 3.3.20
|
|
42
|
+
signing_key:
|
|
43
|
+
specification_version: 4
|
|
44
|
+
summary: Makes an HTTP request to check if a web proxy is working
|
|
45
|
+
test_files: []
|