rangescan 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '091f1965640f47e7388f95a42cc9e787c417fe10431e136d4b1d53903741a7ce'
4
- data.tar.gz: 1bfe329bab43732f42a3ba8416e0bf3ffa9f357684d5c18f2658c19e2670af1b
3
+ metadata.gz: f1d88f06375987da13e9983620c34abb676dfe2b12b3e6b6f6f1f8f85468b7e1
4
+ data.tar.gz: dde41f60761ce812ee29210468c4c685381a0c7431ff0d1e88be841e88500de6
5
5
  SHA512:
6
- metadata.gz: 04a9e7acda25595b2b05efa506a2a9c21364804bda569e3af281399ba46785df6b99625319dfd539ae40a7c0bd06d0a5084a34f47c8d01796703ba325e4228c1
7
- data.tar.gz: '079ec52307a9e18f86baffd3510ec1db8d3cc16f291e68ade601d38a6e0949a9dd8d4c827f10bf9fb43c90d6e9958d6852de99107b73a2f036d49e56c46e995f'
6
+ metadata.gz: c33c2d5f53ca8328b5c04df66cb8856dadf13662ee0477576bd56682d4e223083682fec64f3206deb86ce1065a52ab2fd016d93617f5f5b70190b4ebfbd2a202
7
+ data.tar.gz: e92a5a7cab860c07d571187cb140260d5ba0510d1ac63077b9c41c8e3608a5b2b11893dfbc6cba75835e2e2e5c34bbd569e883e72b8fc16d875d43d139e6756f
@@ -3,6 +3,7 @@
3
3
  require "rangescan/version"
4
4
 
5
5
  require "rangescan/range"
6
+ require "rangescan/utils"
6
7
  require "rangescan/scanner"
7
8
  require "rangescan/matcher"
8
9
 
@@ -24,6 +24,12 @@ module RangeScan
24
24
  @ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE unless verify_ssl
25
25
  end
26
26
 
27
+ def url_for(ipv4)
28
+ return "#{scheme}://#{ipv4}" if (port == 80 && scheme == "http") || (port == 443 && scheme == "https")
29
+
30
+ "#{scheme}://#{ipv4}:#{port}"
31
+ end
32
+
27
33
  def scan(ipv4s)
28
34
  Parallel.map(ipv4s) do |ipv4|
29
35
  get ipv4
@@ -41,7 +47,7 @@ module RangeScan
41
47
  end
42
48
 
43
49
  def get(ipv4)
44
- url = "#{scheme}://#{ipv4}:#{port}"
50
+ url = url_for(ipv4)
45
51
 
46
52
  begin
47
53
  res = HTTP.timeout(timeout).headers(default_headers).get(url, ssl_options)
@@ -49,8 +55,8 @@ module RangeScan
49
55
  url: url,
50
56
  ipv4: ipv4,
51
57
  code: res.code,
52
- headers: res.headers.to_h,
53
- body: res.body.to_s
58
+ headers: Utils.to_utf8(res.headers),
59
+ body: Utils.to_utf8(res.body.to_s)
54
60
  }
55
61
  rescue OpenSSL::SSL::SSLError, HTTP::Error, Addressable::URI::InvalidURIError
56
62
  nil
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RangeScan
4
+ class Utils
5
+ class << self
6
+ def to_utf8(obj)
7
+ return obj.dup.force_encoding(Encoding::UTF_8) if obj.is_a?(String)
8
+
9
+ obj.map do |k, v|
10
+ k = k.dup.force_encoding(Encoding::UTF_8) if k.is_a?(String)
11
+ v = v.dup.force_encoding(Encoding::UTF_8) if v.is_a?(String)
12
+ [k, v]
13
+ end.to_h
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RangeScan
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rangescan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manabu Niseki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-16 00:00:00.000000000 Z
11
+ date: 2020-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -173,6 +173,7 @@ files:
173
173
  - lib/rangescan/matcher.rb
174
174
  - lib/rangescan/range.rb
175
175
  - lib/rangescan/scanner.rb
176
+ - lib/rangescan/utils.rb
176
177
  - lib/rangescan/version.rb
177
178
  - rangescan.gemspec
178
179
  homepage: https://github.com/ninoseki/rangescan