9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/smart_proxy_dns_dnsmasq/dns_dnsmasq_configuration.rb', line 9
def load_dependency_injection_wirings(container_instance, settings)
backend = settings[:backend] || :default
backend = backend.to_s.downcase.to_sym
unless BACKENDS.include? backend
raise ::Proxy::Error::ConfigurationError, "Unknown DNS backend #{backend}, available backends are; #{BACKENDS}"
end
begin
require "smart_proxy_dns_dnsmasq/backend/#{backend}"
rescue LoadError, e
raise ::Proxy::Error::ConfigurationError, e, "Failed to load #{backend} backend"
end
klass = case backend
when :openwrt
::Proxy::Dns::Dnsmasq::Openwrt
when :default
::Proxy::Dns::Dnsmasq::Default
end
container_instance.dependency :dns_provider, (lambda do
klass.new(
settings[:config_path],
settings[:reload_cmd],
settings[:dns_ttl]
)
end)
end
|