Skip to content

Broken compatibility with resolv-replace #44

Open
@Touchstone117

Description

@Touchstone117

Hey,

I think I've found an issue introduced with the change in #10.

Changing from TCPSocket.open to Socket.tcp seems to break the functionality of resolv-replace.

Not sure if this was a by design change and if not if the right place for a fix is here or in resolv-replace itself.

Thanks

A test demonstrating the issue:

gem 'net-http', '0.2.0' # Fails
# gem 'net-http', '0.1.0' # Works
require 'net/http'
require 'resolv-replace'

fake_host = 'not.a.host'

hosts_file_name = 'hosts_file'

hosts_file = "#{Resolv.getaddress('google.com')} #{fake_host}"
File.write(hosts_file_name, hosts_file)

hosts_resolver = Resolv::Hosts.new(hosts_file_name)

dns_resolver = Resolv::DNS.new

Resolv::DefaultResolver.replace_resolvers([hosts_resolver, dns_resolver])

puts Net::HTTP.get(URI("http://#{fake_host}"))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions