Class: Landrush::Action::RedirectDns
- Inherits:
-
Object
- Object
- Landrush::Action::RedirectDns
show all
- Includes:
- Common
- Defined in:
- lib/landrush/action/redirect_dns.rb
Constant Summary
Constants included
from Common
Common::SUPPORTED_PROVIDERS
Instance Method Summary
collapse
Methods included from Common
#enabled?, #global_config, #handle_action_stack, included, #info, #initialize, #machine, #machine_hostname, #provider, #virtualbox?, #vmware?
Instance Method Details
#_gateway_for_ip(ip) ⇒ Object
Poor man’s gateway; strip the last octet and jam a 1 on there.
31
32
33
|
# File 'lib/landrush/action/redirect_dns.rb', line 31
def _gateway_for_ip(ip)
ip.split('.').tap(&:pop).push(1).join('.')
end
|
#_target_host ⇒ Object
21
22
23
24
25
26
27
28
|
# File 'lib/landrush/action/redirect_dns.rb', line 21
def _target_host
case provider
when :virtualbox then
'10.0.2.2'
when :vmware_fusion then
_gateway_for_ip(machine.guest.capability(:configured_dns_server))
end
end
|
#call(env) ⇒ Object
6
7
8
9
10
|
# File 'lib/landrush/action/redirect_dns.rb', line 6
def call(env)
handle_action_stack(env) do
redirect_dns if enabled?
end
end
|
#redirect_dns ⇒ Object
12
13
14
15
16
17
18
19
|
# File 'lib/landrush/action/redirect_dns.rb', line 12
def redirect_dns
info "setting up machine's DNS to point to our server"
machine.guest.capability(:redirect_dns, host: _target_host, port: 10053)
machine.config.vm.networks.each do |type, options|
info "network: #{type.inspect}, #{options.inspect}"
end
end
|