Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursive DNS lookup with Dnsruby::Recursor #141

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/fastly-ips.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
103.245.222.0/23
103.245.224.0/24
104.156.80.0/20
140.248.64.0/18
140.248.128.0/17
146.75.0.0/17
151.101.0.0/16
157.52.64.0/18
Expand Down
6 changes: 5 additions & 1 deletion lib/github-pages-health-check/resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ def initialize(domain, nameservers: :default)
end

def query(type)
resolver.query(Addressable::IDNA.to_ascii(domain), type).answer
recursor.query(Addressable::IDNA.to_ascii(domain), type).answer
end

private

def recursor
@recursor ||= Dnsruby::Recursor.new(resolver)
end

def resolver
@resolver ||= case nameservers
when :default
Expand Down
6 changes: 3 additions & 3 deletions spec/github_pages_health_check/resolver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

context "default" do
it "uses the default resolver" do
expect(described_class.default_resolver).to \
expect(subject.send(:recursor)).to \
receive(:query).with(domain, Dnsruby::Types::A).and_call_original
subject.query(Dnsruby::Types::A)
end
Expand All @@ -21,7 +21,7 @@
it "uses an authoritative resolver" do
expect(described_class.default_resolver).to \
receive(:query).with(domain, Dnsruby::Types::NS).and_call_original
expect(subject.send(:resolver)).to \
expect(subject.send(:recursor)).to \
receive(:query).with(domain, Dnsruby::Types::A).and_call_original
subject.query(Dnsruby::Types::A)
end
Expand All @@ -32,7 +32,7 @@

it "uses the custom resolver" do
expect(subject.send(:resolver).config.nameserver).to eq(nameservers)
expect(subject.send(:resolver)).to \
expect(subject.send(:recursor)).to \
receive(:query).with(domain, Dnsruby::Types::A).and_call_original
subject.query(Dnsruby::Types::A)
end
Expand Down