Skip to content

Instantly share code, notes, and snippets.

@postmodern
Last active October 10, 2017 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save postmodern/4a649d679dbde8dff6a3278dac7f18b0 to your computer and use it in GitHub Desktop.
Save postmodern/4a649d679dbde8dff6a3278dac7f18b0 to your computer and use it in GitHub Desktop.
Resolv::DNS weirdness
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