Socket
Book a DemoInstallSign in
Socket

resolver_replace

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

resolver_replace

0.1.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

resolver-replace

Replace the DNS resolver.

Installation

gem install resolver_replace

How it works

Ruby comes with a pure Ruby replacement, resolv-replace. It replaces the libc resolver with the built-in Resolv class which is a thread-aware DNS resolver library.

This gem works similarly, but allows to replace the resolver with your favorite resolver.

How to use

For example, if you want to replace the resolver with Resolv::DNS, write as followings:

require 'resolv' # Resolv::DNS
require 'resolver_replace' # ResolverReplace

resolver = Resolv::DNS.new(:nameserver => ['210.251.121.21'],
                           :search => ['ruby-lang.org'],
                           :ndots => 1)

ResolverReplace.register!(
  getaddress: Proc.new {|host| resolver.getaddress(host) },
  getaddresses: Proc.new {|host| resolver.getaddresses(host) },
  error_class: Resolv::ResolvError,
)

Plugin

Some gems like mysql2 implement its connection in its C extension without using ruby library. In such case, another monkeypatch must be applied. A plugin scheme of ResolveReplace is ready for such case.

The mysql2 plugin is available for example. Use as followings:

ResolverReplace.load_plugin('mysql2')
ResolverReplace.register!(
  getaddress: Proc.new {|host| resolver.getaddress(host) },
  getaddresses: Proc.new {|host| resolver.getaddresses(host) },
  error_class: Resolv::ResolvError,
)

ChangeLog

See CHANGELOG.md for details.

See Also

Contributing

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

Copyright (c) 2014 Naotoshi Seo. See LICENSE.txt for details.

FAQs

Package last updated on 18 Jul 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.