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

Broken compatibility with resolv-replace #44

Open
Touchstone117 opened this issue Mar 14, 2022 · 1 comment
Open

Broken compatibility with resolv-replace #44

Touchstone117 opened this issue Mar 14, 2022 · 1 comment

Comments

@Touchstone117
Copy link

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}"))
@byroot
Copy link
Member

byroot commented Apr 29, 2022

That sounds more like resolv-replace that should be updated to also patch Scoket.tcp https://github.com/ruby/resolv-replace/blob/master/lib/resolv-replace.rb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants