github-pages-health-check 1.0.1 → 1.1.0

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
  SHA1:
3
- metadata.gz: 4f409efbf6ec37c64dfbfe36da471390fe9ea878
4
- data.tar.gz: 678295ff98baed01729af19b92d48bd1ddbc3209
3
+ metadata.gz: aa3d74adf88a4ef1a35fe97bb48a41c4ddf355c1
4
+ data.tar.gz: 6087da3407bc4f842b86663f115d12aeff5b3e40
5
5
  SHA512:
6
- metadata.gz: 14f33be101c2b6cc8ad42e827642c05b0c30579e4cb6445dd8bfde8480041cd45873b8cc13ce5e7b00a242e2f0b740b5165fdf3d9cac183f1f1eae6f39e6d0df
7
- data.tar.gz: e65246b1a721c6bfe00d446fda2a1eb675b9df92128de07dd75424297e0c4e3507ce0a237c717432e28789f4092a1f5737669b0d3ce6352359f202856cf250ef
6
+ metadata.gz: 1a9290587e49058b6bf7b162b3bf64c0395255039c38484f02386fcb4d1476ee491d6f1554cc5e09ffce95997ecb3a045c4dd22708afef32b81768210b8c4df8
7
+ data.tar.gz: e0804bdec43fd0a892d005df9bae2dcdea39e478ff2f26af215f0ed71c14f5f1f622b5e52469303a7952c4c6da5c0640f8538a0c705271faa25814547e97c583
@@ -29,7 +29,7 @@ module GitHubPages
29
29
  autoload :Printer, "github-pages-health-check/printer"
30
30
 
31
31
  # DNS and HTTP timeout, in seconds
32
- TIMEOUT = 10
32
+ TIMEOUT = 5
33
33
 
34
34
  TYPHOEUS_OPTIONS = {
35
35
  :followlocation => true,
@@ -34,7 +34,8 @@ module GitHubPages
34
34
 
35
35
  # Runs all checks, raises an error if invalid
36
36
  def check!
37
- raise Errors::InvalidDNSError unless dns_resolves?
37
+ raise Errors::InvalidDomainError unless valid_domain?
38
+ raise Errors::InvalidDNSError unless dns_resolves?
38
39
  return true if proxied?
39
40
  raise Errors::DeprecatedIPError if deprecated_ip?
40
41
  raise Errors::InvalidARecordError if invalid_a_record?
@@ -45,7 +46,7 @@ module GitHubPages
45
46
 
46
47
  def deprecated_ip?
47
48
  return @deprecated_ip if defined? @deprecated_ip
48
- @deprecated_ip = (a_record? && old_ip_address?)
49
+ @deprecated_ip = (valid_domain? && a_record? && old_ip_address?)
49
50
  end
50
51
 
51
52
  def invalid_a_record?
@@ -73,10 +74,16 @@ module GitHubPages
73
74
  # Is this domain an apex domain, meaning a CNAME would be innapropriate
74
75
  def apex_domain?
75
76
  return @apex_domain if defined?(@apex_domain)
76
-
77
- answers = Resolv::DNS.open { |dns|
78
- dns.getresources(absolute_domain, Resolv::DNS::Resource::IN::NS)
79
- }
77
+ return unless valid_domain?
78
+
79
+ answers = begin
80
+ Resolv::DNS.open { |dns|
81
+ dns.timeouts = TIMEOUT
82
+ dns.getresources(absolute_domain, Resolv::DNS::Resource::IN::NS)
83
+ }
84
+ rescue Timeout::Error, NoMethodError
85
+ []
86
+ end
80
87
 
81
88
  @apex_domain = answers.any?
82
89
  end
@@ -154,6 +161,7 @@ module GitHubPages
154
161
  # Returns an array of DNS answers
155
162
  def dns
156
163
  return @dns if defined? @dns
164
+ return unless valid_domain?
157
165
  @dns = Timeout.timeout(TIMEOUT) do
158
166
  GitHubPages::HealthCheck.without_warnings do
159
167
  Net::DNS::Resolver.start(absolute_domain).answer unless host.nil?
@@ -198,6 +206,7 @@ module GitHubPages
198
206
 
199
207
  def served_by_pages?
200
208
  return @served_by_pages if defined? @served_by_pages
209
+ return unless dns_resolves?
201
210
 
202
211
  @served_by_pages = begin
203
212
  response = Typhoeus.head(uri, TYPHOEUS_OPTIONS)
@@ -1,5 +1,5 @@
1
1
  module GitHubPages
2
2
  module HealthCheck
3
- VERSION = "1.0.1"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github-pages-health-check
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-17 00:00:00.000000000 Z
11
+ date: 2016-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-dns
@@ -212,7 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
212
212
  version: '0'
213
213
  requirements: []
214
214
  rubyforge_project:
215
- rubygems_version: 2.5.2
215
+ rubygems_version: 2.6.1
216
216
  signing_key:
217
217
  specification_version: 4
218
218
  summary: Checks your GitHub Pages site for commons DNS configuration issues