Class: VagrantPlugins::DNS::Action::CreateResolvers
- Inherits:
-
Object
- Object
- VagrantPlugins::DNS::Action::CreateResolvers
- Defined in:
- lib/vagrant-dns/action/create_resolvers.rb
Overview
Create resolver files in ~/.vagrant.d/tmp/dns/resolver
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ CreateResolvers
constructor
A new instance of CreateResolvers.
Constructor Details
#initialize(app, env) ⇒ CreateResolvers
Returns a new instance of CreateResolvers.
6 7 8 |
# File 'lib/vagrant-dns/action/create_resolvers.rb', line 6 def initialize(app, env) @app = app end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/vagrant-dns/action/create_resolvers.rb', line 10 def call(env) unless env[:machine].config.dns.enabled return @app.call(env) end tmp_dns_path = env[:dns].tmp_path resolver_folder = File.join(tmp_dns_path, "resolver") port = VagrantPlugins::DNS.listen.first.last # 5300 tlds = env[:machine].config.dns.tlds FileUtils.mkdir_p(resolver_folder) tlds.each do |tld| File.open(File.join(resolver_folder, tld), "w") do |f| f << resolver_file(port) end end env[:dns].ui.info "Created resolvers for tlds #{tlds}" @app.call(env) end |