resolv-replace 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +30 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/resolv-replace.rb +76 -0
- data/resolv-replace.gemspec +24 -0
- metadata +69 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 23c53e4293723e3d0cc154a04b18370e890f9443679fbf77c4a123f17288238e
|
4
|
+
data.tar.gz: 7d9c4e6b49d1885e3a996dd042c91960c6b4b457f60f9f5578aa58a91d314483
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c060c5efc855fee8c97f9da9108d684a4a9abc7363afecc3cfd81fa1b02282dac403a94f512429ceb2ee4f6fa1c1516bde6e57551ce979c70be38ced84ee6beb
|
7
|
+
data.tar.gz: 4d105f9bfd70e91652abc095fa951df6b9f2dddddb66a3a03e00dfcb5778f1b813ceee3ae07569f844d5c3b8a07cb1f48006bea79afca3ccbd492f99ca7a72b5
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (C) 1993-2013 Yukihiro Matsumoto. All rights reserved.
|
2
|
+
|
3
|
+
Redistribution and use in source and binary forms, with or without
|
4
|
+
modification, are permitted provided that the following conditions
|
5
|
+
are met:
|
6
|
+
1. Redistributions of source code must retain the above copyright
|
7
|
+
notice, this list of conditions and the following disclaimer.
|
8
|
+
2. Redistributions in binary form must reproduce the above copyright
|
9
|
+
notice, this list of conditions and the following disclaimer in the
|
10
|
+
documentation and/or other materials provided with the distribution.
|
11
|
+
|
12
|
+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
13
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
14
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
15
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
16
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
17
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
18
|
+
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
19
|
+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
20
|
+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
21
|
+
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
22
|
+
SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# resolv-replace.rb
|
2
|
+
|
3
|
+
Replace Socket DNS with Resolv
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'resolv-replace'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle install
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install resolv-replace
|
20
|
+
|
21
|
+
## Development
|
22
|
+
|
23
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
24
|
+
|
25
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/resolv-replace.
|
30
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "resolv/replace"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'socket'
|
4
|
+
require 'resolv'
|
5
|
+
|
6
|
+
class << IPSocket
|
7
|
+
# :stopdoc:
|
8
|
+
alias original_resolv_getaddress getaddress
|
9
|
+
# :startdoc:
|
10
|
+
def getaddress(host)
|
11
|
+
begin
|
12
|
+
return Resolv.getaddress(host).to_s
|
13
|
+
rescue Resolv::ResolvError
|
14
|
+
raise SocketError, "Hostname not known: #{host}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class TCPSocket < IPSocket
|
20
|
+
# :stopdoc:
|
21
|
+
alias original_resolv_initialize initialize
|
22
|
+
# :startdoc:
|
23
|
+
def initialize(host, serv, *rest)
|
24
|
+
rest[0] = IPSocket.getaddress(rest[0]) if rest[0]
|
25
|
+
original_resolv_initialize(IPSocket.getaddress(host), serv, *rest)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class UDPSocket < IPSocket
|
30
|
+
# :stopdoc:
|
31
|
+
alias original_resolv_bind bind
|
32
|
+
# :startdoc:
|
33
|
+
def bind(host, port)
|
34
|
+
host = IPSocket.getaddress(host) if host != ""
|
35
|
+
original_resolv_bind(host, port)
|
36
|
+
end
|
37
|
+
|
38
|
+
# :stopdoc:
|
39
|
+
alias original_resolv_connect connect
|
40
|
+
# :startdoc:
|
41
|
+
def connect(host, port)
|
42
|
+
original_resolv_connect(IPSocket.getaddress(host), port)
|
43
|
+
end
|
44
|
+
|
45
|
+
# :stopdoc:
|
46
|
+
alias original_resolv_send send
|
47
|
+
# :startdoc:
|
48
|
+
def send(mesg, flags, *rest)
|
49
|
+
if rest.length == 2
|
50
|
+
host, port = rest
|
51
|
+
begin
|
52
|
+
addrs = Resolv.getaddresses(host)
|
53
|
+
rescue Resolv::ResolvError
|
54
|
+
raise SocketError, "Hostname not known: #{host}"
|
55
|
+
end
|
56
|
+
addrs[0...-1].each {|addr|
|
57
|
+
begin
|
58
|
+
return original_resolv_send(mesg, flags, addr, port)
|
59
|
+
rescue SystemCallError
|
60
|
+
end
|
61
|
+
}
|
62
|
+
original_resolv_send(mesg, flags, addrs[-1], port)
|
63
|
+
else
|
64
|
+
original_resolv_send(mesg, flags, *rest)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
class SOCKSSocket < TCPSocket
|
70
|
+
# :stopdoc:
|
71
|
+
alias original_resolv_initialize initialize
|
72
|
+
# :startdoc:
|
73
|
+
def initialize(host, serv)
|
74
|
+
original_resolv_initialize(IPSocket.getaddress(host), port)
|
75
|
+
end
|
76
|
+
end if defined? SOCKSSocket
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "resolv-replace"
|
3
|
+
spec.version = "0.1.0"
|
4
|
+
spec.authors = ["Tanaka Akira"]
|
5
|
+
spec.email = ["akr@fsij.org"]
|
6
|
+
|
7
|
+
spec.summary = %q{Replace Socket DNS with Resolv.}
|
8
|
+
spec.description = %q{Replace Socket DNS with Resolv.}
|
9
|
+
spec.homepage = "https://github.com/ruby/resolv-replace"
|
10
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
11
|
+
spec.licenses = ["Ruby", "BSD-2-Clause"]
|
12
|
+
|
13
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
14
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
15
|
+
|
16
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
17
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_dependency "resolv"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: resolv-replace
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tanaka Akira
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-09-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: resolv
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Replace Socket DNS with Resolv.
|
28
|
+
email:
|
29
|
+
- akr@fsij.org
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".gitignore"
|
35
|
+
- Gemfile
|
36
|
+
- LICENSE.txt
|
37
|
+
- README.md
|
38
|
+
- Rakefile
|
39
|
+
- bin/console
|
40
|
+
- bin/setup
|
41
|
+
- lib/resolv-replace.rb
|
42
|
+
- resolv-replace.gemspec
|
43
|
+
homepage: https://github.com/ruby/resolv-replace
|
44
|
+
licenses:
|
45
|
+
- Ruby
|
46
|
+
- BSD-2-Clause
|
47
|
+
metadata:
|
48
|
+
homepage_uri: https://github.com/ruby/resolv-replace
|
49
|
+
source_code_uri: https://github.com/ruby/resolv-replace
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options: []
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: 2.3.0
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
requirements: []
|
65
|
+
rubygems_version: 3.2.0.rc.1
|
66
|
+
signing_key:
|
67
|
+
specification_version: 4
|
68
|
+
summary: Replace Socket DNS with Resolv.
|
69
|
+
test_files: []
|