Revert "dig shouldn't bomb-out if forbidden hyphen is used"

DiG 9.10.6 no longer has the `+noidn` option, and `dig` will error if we
try to use it.

fixes:
```
dig +short +noidnin ns sslip.io @ns-azure.nono.io.
Invalid option: +noidnin
```

And this previously-invalid dig query now works, so we don't need the
option anyway:
```
dig +short AAAA api.--.sslip.io
::
```

This reverts commit a2564c12d3.
This commit is contained in:
Brian Cunnie
2020-12-01 09:13:07 -08:00
parent 0ac9e1895d
commit 06f1556699

View File

@@ -17,19 +17,11 @@ def get_whois_nameservers(domain)
nameservers nameservers
end end
def idn_dig?
system("dig -h | grep idn")
end
domain = ENV['DOMAIN'] || 'example.com' domain = ENV['DOMAIN'] || 'example.com'
whois_nameservers = get_whois_nameservers(domain) whois_nameservers = get_whois_nameservers(domain)
describe domain do describe domain do
soa = nil soa = nil
idn_dig = `dig -h | grep idn`
dig_args = "+short"
dig_args += idn_dig? ? " +noidnin" : ""
context "when evaluating $DOMAIN (\"#{domain}\") environment variable" do context "when evaluating $DOMAIN (\"#{domain}\") environment variable" do
let (:domain) { ENV['DOMAIN'] } let (:domain) { ENV['DOMAIN'] }
@@ -46,55 +38,55 @@ describe domain do
end end
whois_nameservers.each do |whois_nameserver| whois_nameservers.each do |whois_nameserver|
it "nameserver #{whois_nameserver}'s NS records match whois's, " + it "nameserver #{whois_nameserver}'s NS records match whois's #{whois_nameservers}, " +
"`dig #{dig_args} ns sslip.io @#{whois_nameserver}`" do "`dig +short ns sslip.io @#{whois_nameserver}`" do
dig_nameservers = `dig #{dig_args} ns sslip.io @#{whois_nameserver}`.split(/\n+/) dig_nameservers = `dig +short ns sslip.io @#{whois_nameserver}`.split(/\n+/)
expect(dig_nameservers.sort).to eq(whois_nameservers.sort) expect(dig_nameservers.sort).to eq(whois_nameservers.sort)
end end
it "nameserver #{whois_nameserver}'s SOA record match" do it "nameserver #{whois_nameserver}'s SOA record match" do
dig_soa = `dig #{dig_args} soa sslip.io @#{whois_nameserver}` dig_soa = `dig +short soa sslip.io @#{whois_nameserver}`
soa = soa || dig_soa soa = soa || dig_soa
expect(dig_soa).to eq(soa) expect(dig_soa).to eq(soa)
end end
a = [ rand(256), rand(256), rand(256), rand(256) ] a = [ rand(256), rand(256), rand(256), rand(256) ]
it "nameserver #{whois_nameserver} resolves #{a.join(".")}.sslip.io to #{a.join(".")}" do it "resolves #{a.join(".")}.sslip.io to #{a.join(".")}" do
expect(`dig #{dig_args} #{a.join(".") + "." + domain} @#{whois_nameserver}`.chomp).to eq(a.join(".")) expect(`dig +short #{a.join(".") + "." + domain} @#{whois_nameserver}`.chomp).to eq(a.join("."))
end end
a = [ rand(256), rand(256), rand(256), rand(256) ] a = [ rand(256), rand(256), rand(256), rand(256) ]
it "nameserver #{whois_nameserver} resolves #{a.join("-")}.sslip.io to #{a.join(".")}" do it "resolves #{a.join("-")}.sslip.io to #{a.join(".")}" do
expect(`dig #{dig_args} #{a.join("-") + "." + domain} @#{whois_nameserver}`.chomp).to eq(a.join(".")) expect(`dig +short #{a.join("-") + "." + domain} @#{whois_nameserver}`.chomp).to eq(a.join("."))
end end
a = [ rand(256), rand(256), rand(256), rand(256) ] a = [ rand(256), rand(256), rand(256), rand(256) ]
b = [ ('a'..'z').to_a, ('0'..'9').to_a ].flatten.shuffle[0,8].join b = [ ('a'..'z').to_a, ('0'..'9').to_a ].flatten.shuffle[0,8].join
it "nameserver #{whois_nameserver} resolves #{b}.#{a.join("-")}.sslip.io to #{a.join(".")}" do it "resolves #{b}.#{a.join("-")}.sslip.io to #{a.join(".")}" do
expect(`dig #{dig_args} #{b}.#{a.join("-") + "." + domain} @#{whois_nameserver}`.chomp).to eq(a.join(".")) expect(`dig +short #{b}.#{a.join("-") + "." + domain} @#{whois_nameserver}`.chomp).to eq(a.join("."))
end end
a = [ rand(256), rand(256), rand(256), rand(256) ] a = [ rand(256), rand(256), rand(256), rand(256) ]
b = [ ('a'..'z').to_a, ('0'..'9').to_a ].flatten.shuffle[0,8].join b = [ ('a'..'z').to_a, ('0'..'9').to_a ].flatten.shuffle[0,8].join
it "nameserver #{whois_nameserver} resolves #{a.join("-")}.#{b} to #{a.join(".")}" do it "resolves #{a.join("-")}.#{b} to #{a.join(".")}" do
expect(`dig #{dig_args} #{a.join("-") + "." + b} @#{whois_nameserver}`.chomp).to eq(a.join(".")) expect(`dig +short #{a.join("-") + "." + b} @#{whois_nameserver}`.chomp).to eq(a.join("."))
end end
# don't begin the hostname with a double-dash -- `dig` mistakes it for an argument # don't begin the hostname with a double-dash -- `dig` mistakes it for an argument
it "nameserver #{whois_nameserver} resolves api.--.sslip.io' to eq ::)}" do it "resolves api.--.sslip.io' to eq ::)}" do
expect(`dig #{dig_args} AAAA api.--.sslip.io @#{whois_nameserver}`.chomp).to eq("::") expect(`dig +short AAAA api.--.sslip.io @#{whois_nameserver}`.chomp).to eq("::")
end end
it "nameserver #{whois_nameserver} resolves localhost.--1.sslip.io' to eq ::1)}" do it "resolves localhost.--1.sslip.io' to eq ::1)}" do
expect(`dig #{dig_args} AAAA localhost.api.--1.sslip.io @#{whois_nameserver}`.chomp).to eq("::1") expect(`dig +short AAAA localhost.api.--1.sslip.io @#{whois_nameserver}`.chomp).to eq("::1")
end end
it "nameserver #{whois_nameserver} resolves 2001-4860-4860--8888.sslip.io' to eq 2001:4860:4860::8888)}" do it "resolves 2001-4860-4860--8888.sslip.io' to eq 2001:4860:4860::8888)}" do
expect(`dig #{dig_args} AAAA 2001-4860-4860--8888.sslip.io @#{whois_nameserver}`.chomp).to eq("2001:4860:4860::8888") expect(`dig +short AAAA 2001-4860-4860--8888.sslip.io @#{whois_nameserver}`.chomp).to eq("2001:4860:4860::8888")
end end
it "nameserver #{whois_nameserver} resolves 2601-646-100-69f0--24.sslip.io' to eq 2601:646:100:69f0::24)}" do it "resolves 2601-646-100-69f0--24.sslip.io' to eq 2601:646:100:69f0::24)}" do
expect(`dig #{dig_args} AAAA 2601-646-100-69f0--24.sslip.io @#{whois_nameserver}`.chomp).to eq("2601:646:100:69f0::24") expect(`dig +short AAAA 2601-646-100-69f0--24.sslip.io @#{whois_nameserver}`.chomp).to eq("2601:646:100:69f0::24")
end end
end end
end end