dimscan 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dimscan.rb +6 -0
- data/lib/dimscan/http_byte_enumerator.rb +25 -7
- data/lib/dimscan/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d23ddb35aeff44c2ee1146b91d8b9b909bccbf9
|
4
|
+
data.tar.gz: d5e250c9f69895d437337cbc733b6c8a1687cb49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c12df6b388957fdf2867a44e86851acdfa39b41bc3e219af5fdb929735aef914ba8c207e9415e4db64e8e5439739f0b97dbaa4b43fe45ea988b98f327d2d8897
|
7
|
+
data.tar.gz: 78ccee05a9a10ea415fb4104d61c9cf14a774eeaccc40c56917384332dc425b87f9a2c5ae86ad72da1e0467564c1ac1c62ad562f0ae660f61fcdbc139819ace4
|
data/lib/dimscan.rb
CHANGED
@@ -4,6 +4,25 @@ require 'net/http'
|
|
4
4
|
module Dimscan
|
5
5
|
# A utility class for enumerating over the bytes of a http response body
|
6
6
|
class HTTPByteEnumerator
|
7
|
+
@connections = {}
|
8
|
+
class << self
|
9
|
+
def open_connection(host, port, ssl)
|
10
|
+
@connections[host] ||= {}
|
11
|
+
@connections[host][port] ||= {}
|
12
|
+
@connections[host][port][ssl] ||= Net::HTTP.start(
|
13
|
+
host, port, use_ssl: ssl
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
def close_connections
|
18
|
+
@connections.values.each do |ports|
|
19
|
+
ports.values.each do |connections|
|
20
|
+
connections.values.each(&:finish)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
7
26
|
def initialize(url)
|
8
27
|
@uri = URI(url)
|
9
28
|
fail ArgumentError, 'invalid scheme' unless @uri.scheme =~ /^https?$/
|
@@ -12,13 +31,12 @@ module Dimscan
|
|
12
31
|
def each(&block)
|
13
32
|
return to_enum(__callee__) unless block_given?
|
14
33
|
request = Net::HTTP::Get.new(@uri)
|
15
|
-
|
16
|
-
@uri.host, @uri.port,
|
17
|
-
)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
34
|
+
http = self.class.open_connection(
|
35
|
+
@uri.host, @uri.port, @uri.scheme == 'https'
|
36
|
+
)
|
37
|
+
http.request(request) do |response|
|
38
|
+
fail response.body if error?(response)
|
39
|
+
enumerate_response(response, &block)
|
22
40
|
end
|
23
41
|
end
|
24
42
|
|
data/lib/dimscan/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dimscan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joakim Reinert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|