Skip to content

Commit

Permalink
Implement passthrough
Browse files Browse the repository at this point in the history
  • Loading branch information
skade committed May 14, 2012
1 parent 16a37f4 commit 1377a91
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
# v0.2.4

* Enable passthrough in DNS service. Helpful if you insist to hook a standard tld like .io.

# v0.2.3

* Remove unneeded iteraton in installers/mac.rb. (thanks to JonathanTron for reporting)
Expand Down
20 changes: 20 additions & 0 deletions lib/vagrant-dns/service.rb
Expand Up @@ -19,16 +19,36 @@ def stop!

def run!(run_options)
Daemons.run_proc("vagrant-dns", run_options) do
require 'resolv'
require 'rubydns'

# come on, this is Ruby
# Ruby 1.9.3 does not implement :make_requester anymore
# Luckily :make_udp_requester is just the same
begin
Resolv::DNS.instance_method(:make_requester)
rescue NameError
Resolv::DNS.class_eval {
alias :make_requester :make_udp_requester
}
end

registry = YAML.load(File.read(config_file))
std_resolver = Resolv::DNS.new

RubyDNS::run_server(:listen => VagrantDNS::Config.listen) do
registry.each do |pattern, ip|
match(Regexp.new(pattern), :A) do |match_data, transaction|
transaction.respond!(ip)
end
end

otherwise do |transaction|
transaction.passthrough!(std_resolver) do |reply, reply_name|
puts reply
puts reply_name
end
end
end
end
end
Expand Down

0 comments on commit 1377a91

Please sign in to comment.