github-pages-health-check 0.1.1 → 0.2.1
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8c1e7a34024d690e47658f6bcb88c19c106766f
|
4
|
+
data.tar.gz: 287d09be090db2528a6fccc9ca2129c900ff2cad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4eb4ad2eed9c77f0bb65b74b0c9e008c6a7a1a52d77c661e9a948fd0748e02793cf13cf169d49dea37486740679e336c14155d287d9b1b5b91eb8d649e21438f
|
7
|
+
data.tar.gz: 2f607148537eb2adb88623cbe32b17ed8d54af91afff7432d9efd2e38183743afd367c94b7825329ae90cc7b8ca3a9188ebecea0876b7bdac7435b80d91c5d25
|
@@ -3,12 +3,14 @@ require 'net/dns/resolver'
|
|
3
3
|
require 'ipaddr'
|
4
4
|
require 'public_suffix'
|
5
5
|
require 'singleton'
|
6
|
+
require 'net/http'
|
6
7
|
require_relative 'github-pages-health-check/version'
|
7
8
|
require_relative 'github-pages-health-check/cloudflare'
|
8
9
|
require_relative 'github-pages-health-check/error'
|
9
10
|
require_relative 'github-pages-health-check/errors/deprecated_ip'
|
10
11
|
require_relative 'github-pages-health-check/errors/invalid_a_record'
|
11
12
|
require_relative 'github-pages-health-check/errors/invalid_cname'
|
13
|
+
require_relative 'github-pages-health-check/errors/not_served_by_pages'
|
12
14
|
|
13
15
|
class GitHubPages
|
14
16
|
class HealthCheck
|
@@ -81,6 +83,11 @@ class GitHubPages
|
|
81
83
|
!!domain.match(/^[\w-]+\.github\.(io|com)\.?$/i)
|
82
84
|
end
|
83
85
|
|
86
|
+
# Is this domain owned by GitHub?
|
87
|
+
def github_domain?
|
88
|
+
!!domain.match(/\.github\.com$/)
|
89
|
+
end
|
90
|
+
|
84
91
|
def to_hash
|
85
92
|
{
|
86
93
|
:cloudflare_ip? => cloudflare_ip?,
|
@@ -92,11 +99,21 @@ class GitHubPages
|
|
92
99
|
:should_be_a_record? => should_be_a_record?,
|
93
100
|
:pointed_to_github_user_domain? => pointed_to_github_user_domain?,
|
94
101
|
:pages_domain? => pages_domain?,
|
102
|
+
:served_by_pages? => served_by_pages?,
|
95
103
|
:valid? => valid?,
|
96
104
|
:reason => reason
|
97
105
|
}
|
98
106
|
end
|
99
107
|
|
108
|
+
def served_by_pages?
|
109
|
+
scheme = github_domain? ? "https" : "http"
|
110
|
+
uri = URI("#{scheme}://#{domain}")
|
111
|
+
response = Net::HTTP.get_response(uri)
|
112
|
+
response.to_hash["server"] == ["GitHub.com"]
|
113
|
+
rescue
|
114
|
+
false
|
115
|
+
end
|
116
|
+
|
100
117
|
def to_json
|
101
118
|
to_hash.to_json
|
102
119
|
end
|
@@ -107,7 +124,8 @@ class GitHubPages
|
|
107
124
|
return if cloudflare_ip?
|
108
125
|
raise DeprecatedIP if a_record? && old_ip_address?
|
109
126
|
raise InvalidARecord if valid_domain? && a_record? && !should_be_a_record?
|
110
|
-
raise InvalidCNAME if valid_domain? && !apex_domain? && !pointed_to_github_user_domain?
|
127
|
+
raise InvalidCNAME if valid_domain? && !github_domain? && !apex_domain? && !pointed_to_github_user_domain?
|
128
|
+
raise NotServedByPages unless served_by_pages?
|
111
129
|
true
|
112
130
|
end
|
113
131
|
alias_method :valid!, :check!
|
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: 0.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-dns
|
@@ -94,6 +94,7 @@ files:
|
|
94
94
|
- lib/github-pages-health-check/errors/deprecated_ip.rb
|
95
95
|
- lib/github-pages-health-check/errors/invalid_a_record.rb
|
96
96
|
- lib/github-pages-health-check/errors/invalid_cname.rb
|
97
|
+
- lib/github-pages-health-check/errors/not_served_by_pages.rb
|
97
98
|
- lib/github-pages-health-check/version.rb
|
98
99
|
homepage: https://github.com/github/github-pages-health-check
|
99
100
|
licenses:
|