Last active
October 10, 2017 17:44
-
-
Save postmodern/4a649d679dbde8dff6a3278dac7f18b0 to your computer and use it in GitHub Desktop.
Resolv::DNS weirdness
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'resolv' | |
puts "Normal behavior:" | |
dns = Resolv::DNS.new | |
p dns.getaddresses('twitter.com') | |
# => [#<Resolv::IPv4 104.244.42.1>, #<Resolv::IPv4 104.244.42.193>] | |
puts "With search: option:" | |
dns = Resolv::DNS.new(search: ['.']) | |
p dns.getaddresses('twitter.com') | |
# => [] | |
puts "With ndots: option:" | |
dns = Resolv::DNS.new(ndots: 1) | |
p dns.getaddresses('twitter.com') | |
# => [] | |
puts "With search: and ndots: options:" | |
dns = Resolv::DNS.new(search: ['.'], ndots: 1) | |
p dns.getaddresses('twitter.com') | |
# => [] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment