Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sonots/resolver_replace
Replace the DNS resolver
https://github.com/sonots/resolver_replace
Last synced: about 2 months ago
JSON representation
Replace the DNS resolver
- Host: GitHub
- URL: https://github.com/sonots/resolver_replace
- Owner: sonots
- License: mit
- Created: 2014-06-24T13:25:16.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-07-18T13:26:50.000Z (over 10 years ago)
- Last Synced: 2024-10-13T08:08:43.223Z (3 months ago)
- Language: Ruby
- Size: 297 KB
- Stars: 2
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# resolver-replace
Replace the DNS resolver.
## Installation
```bash
gem install resolver_replace
```## How it works
Ruby comes with a pure Ruby replacement, [resolv-replace](https://github.com/ruby/ruby/blob/b1f2effda85efd03bd4ad5c06e0aae5e14f3f864/lib/resolv-replace.rb).
It replaces the libc resolver with the built-in [Resolv](http://apidock.com/ruby/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:
```ruby
require 'resolv' # Resolv::DNS
require 'resolver_replace' # ResolverReplaceresolver = 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:
```ruby
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](CHANGELOG.md) for details.
## See Also
* [例えば Resolver をすげかえる - sonots:blog](http://blog.livedoor.jp/sonots/archives/38822072.html)
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new [Pull Request](../../pull/new/master)## Copyright
Copyright (c) 2014 Naotoshi Seo. See [LICENSE.txt](LICENSE.txt) for details.