Skip to content

Commit 209be81

Browse files
authored
Merge pull request #140 from github/ipv6-fix
IPv6 fix
2 parents 06621a8 + fe4a96d commit 209be81

File tree

5 files changed

+36
-10
lines changed

5 files changed

+36
-10
lines changed

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Style/ClassAndModuleChildren:
5252
Enabled: false # module X<\n>module Y is just as good as module X::Y.
5353

5454
Layout/LineLength:
55-
Max: 90
55+
Max: 120
5656
Severity: warning
5757
Exclude:
5858
- github-pages-health-check.gemspec

lib/github-pages-health-check/domain.rb

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class Domain < Checkable
8989

9090
HASH_METHODS = %i[
9191
host uri nameservers dns_resolves? proxied? cloudflare_ip?
92-
fastly_ip? old_ip_address? a_record? aaaa_record? aaaa_record_present?
92+
fastly_ip? old_ip_address? a_record? aaaa_record? a_record_present? aaaa_record_present?
9393
cname_record? mx_records_present? valid_domain? apex_domain?
9494
should_be_a_record? cname_to_github_user_domain?
9595
cname_to_pages_dot_github_dot_com? cname_to_fastly?
@@ -138,14 +138,13 @@ def deprecated_ip?
138138
def invalid_aaaa_record?
139139
return @invalid_aaaa_record if defined? @invalid_aaaa_record
140140

141-
@invalid_aaaa_record =
142-
(valid_domain? && aaaa_record_present? && !should_be_a_record?)
141+
@invalid_aaaa_record = (valid_domain? && aaaa_record_present? && !should_be_a_record?)
143142
end
144143

145144
def invalid_a_record?
146145
return @invalid_a_record if defined? @invalid_a_record
147146

148-
@invalid_a_record = (valid_domain? && a_record? && !should_be_a_record?)
147+
@invalid_a_record = (valid_domain? && a_record_present? && !should_be_a_record?)
149148
end
150149

151150
def invalid_cname?
@@ -369,10 +368,18 @@ def aaaa_record?
369368
@is_aaaa_record = Dnsruby::Types::AAAA == dns.first.type
370369
end
371370

371+
# Does this domain has an A record setup (not necessarily as the first record)?
372+
def a_record_present?
373+
return unless dns?
374+
375+
dns.any? { |answer| answer.type == Dnsruby::Types::A && answer.name.to_s == host }
376+
end
377+
378+
# Does this domain has an AAAA record setup (not necessarily as the first record)?
372379
def aaaa_record_present?
373380
return unless dns?
374381

375-
dns.any? { |answer| answer.type == Dnsruby::Types::AAAA }
382+
dns.any? { |answer| answer.type == Dnsruby::Types::AAAA && answer.name.to_s == host }
376383
end
377384

378385
# Is this domain's first response a CNAME record?

lib/github-pages-health-check/errors/invalid_aaaa_record_error.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ class InvalidAAAARecordError < GitHubPages::HealthCheck::Error
88

99
def message
1010
<<-MSG
11-
Your site's DNS settings are using a custom subdomain, #{domain.host},
12-
that's set up with an AAAA record. GitHub Pages currently does not support
13-
IPv6.
11+
Your site's DNS settings are using a custom subdomain, #{domain.host},
12+
that's set up as an AAAA record. We recommend you change this to a CNAME
13+
record pointing at #{username}.github.io.
1414
MSG
1515
end
1616
end

lib/github-pages-health-check/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
module GitHubPages
44
module HealthCheck
5-
VERSION = "1.17.8"
5+
VERSION = "1.17.9"
66
end
77
end

spec/github_pages_health_check/domain_spec.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,25 @@
180180
end
181181
end
182182

183+
context "A & AAAA recursive resolutions" do
184+
let(:domain) { "domain.com" }
185+
let(:cname) { "domain.github.io" }
186+
before(:each) do
187+
allow(subject).to receive(:dns) {
188+
[
189+
cname_packet,
190+
Dnsruby::RR.create("#{cname}. 1000 IN A #{ip}"),
191+
Dnsruby::RR.create("#{cname}. 1000 IN AAAA #{ip6}")
192+
]
193+
}
194+
end
195+
196+
it "does not get tricked by recursive resolution" do
197+
expect(subject).to_not be_an_aaaa_record_present
198+
expect(subject).to_not be_an_a_record_present
199+
end
200+
end
201+
183202
context "CNAMEs" do
184203
before(:each) { allow(subject).to receive(:dns) { [cname_packet] } }
185204

0 commit comments

Comments
 (0)