smart_proxy_dns_dnsmasq 0.5 → 0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/dns_dnsmasq.yml +1 -1
- data/lib/smart_proxy_dns_dnsmasq/backend/default.rb +9 -9
- data/lib/smart_proxy_dns_dnsmasq/dns_dnsmasq_configuration.rb +14 -12
- data/lib/smart_proxy_dns_dnsmasq/dns_dnsmasq_plugin.rb +1 -1
- data/lib/smart_proxy_dns_dnsmasq/dns_dnsmasq_version.rb +1 -1
- data/test/dns_dnsmasq_default_settings_test.rb +2 -2
- data/test/dns_dnsmasq_production_wiring_test.rb +4 -2
- data/test/dns_dnsmasq_record_default_test.rb +10 -10
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50d4032f443de747d784de78eb8bbf0ca97b236a
|
4
|
+
data.tar.gz: 88ec43f74a5c58deac1d4d41b53cf6c08e848c27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ae2ab7e58dd195c8b66663f61d7abba7ca0ee2567ecd0371935855bef256b0ae57ecfd005dd9984551351556f864ac8b40b09f1a32807ab456095c1ca5040fb
|
7
|
+
data.tar.gz: 38a647b8bec5943708698dbc127f5f6e1d5cc88972bd34c3e4e7341e86cbe4580a8f24f97aeaa9998d49ec8fecbb79857363638356ae7d01b50f675e09194e3a
|
data/config/dns_dnsmasq.yml
CHANGED
@@ -35,12 +35,13 @@ module Proxy::Dns::Dnsmasq
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def remove_entry(type, fqdn = nil, ip = nil)
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
38
|
+
e = case type
|
39
|
+
when 'A', 'AAAA'
|
40
|
+
configuration.find { |entry| entry.is_a?(AddressEntry) && entry.fqdn.include?(fqdn) }
|
41
|
+
when 'PTR'
|
42
|
+
configuration.find { |entry| entry.is_a?(PTREntry) && entry.ip.include?(ip.split('.').reverse.join('.')) }
|
43
|
+
end
|
44
|
+
return true unless e
|
44
45
|
|
45
46
|
configuration.delete e
|
46
47
|
@dirty = true
|
@@ -95,9 +96,8 @@ module Proxy::Dns::Dnsmasq
|
|
95
96
|
data = value.split(',')
|
96
97
|
|
97
98
|
entry = PTREntry.new
|
98
|
-
entry.ip = data
|
99
|
-
entry.fqdn = data
|
100
|
-
|
99
|
+
entry.ip = data[0]
|
100
|
+
entry.fqdn = data[1]
|
101
101
|
# TODO: Handle these properly
|
102
102
|
# when 'host-record'
|
103
103
|
# data = value.split(',')
|
@@ -5,32 +5,34 @@ module ::Proxy::Dns::Dnsmasq
|
|
5
5
|
require 'smart_proxy_dns_dnsmasq/dns_dnsmasq_main'
|
6
6
|
end
|
7
7
|
|
8
|
-
BACKENDS =
|
8
|
+
BACKENDS = %i(openwrt default).freeze
|
9
9
|
def load_dependency_injection_wirings(container_instance, settings)
|
10
|
-
backend = settings[:backend] ||
|
10
|
+
backend = settings[:backend] || :default
|
11
|
+
backend = backend.to_s.downcase.to_sym
|
11
12
|
|
12
13
|
unless BACKENDS.include? backend
|
13
|
-
raise ::Proxy::Error::ConfigurationError,
|
14
|
+
raise ::Proxy::Error::ConfigurationError, "Unknown DNS backend #{backend}, available backends are; #{BACKENDS}"
|
14
15
|
end
|
15
16
|
|
16
17
|
begin
|
17
18
|
require "smart_proxy_dns_dnsmasq/backend/#{backend}"
|
18
19
|
rescue LoadError, e
|
19
|
-
raise ::Proxy::Error::ConfigurationError, "Failed to load
|
20
|
+
raise ::Proxy::Error::ConfigurationError, e, "Failed to load #{backend} backend"
|
20
21
|
end
|
21
22
|
|
22
23
|
klass = case backend
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
when :openwrt
|
25
|
+
::Proxy::Dns::Dnsmasq::Openwrt
|
26
|
+
when :default
|
27
|
+
::Proxy::Dns::Dnsmasq::Default
|
28
|
+
end
|
28
29
|
|
29
30
|
container_instance.dependency :dns_provider, (lambda do
|
30
31
|
klass.new(
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
settings[:config_path],
|
33
|
+
settings[:reload_cmd],
|
34
|
+
settings[:dns_ttl]
|
35
|
+
)
|
34
36
|
end)
|
35
37
|
end
|
36
38
|
end
|
@@ -9,7 +9,7 @@ module Proxy::Dns::Dnsmasq
|
|
9
9
|
# An exception will be raised if they are initialized with nil values.
|
10
10
|
# Settings not listed under default_settings are considered optional and by default have nil value.
|
11
11
|
default_settings :config_path => '/etc/dnsmasq.d/foreman.conf',
|
12
|
-
:reload_cmd
|
12
|
+
:reload_cmd => 'systemctl restart dnsmasq'
|
13
13
|
|
14
14
|
requires :dns, '>= 1.15'
|
15
15
|
|
@@ -5,7 +5,7 @@ require 'smart_proxy_dns_dnsmasq/dns_dnsmasq_plugin'
|
|
5
5
|
class DnsDnsmasqDefaultSettingsTest < Test::Unit::TestCase
|
6
6
|
def test_default_settings
|
7
7
|
Proxy::Dns::Dnsmasq::Plugin.load_test_settings({})
|
8
|
-
assert_equal
|
9
|
-
assert_equal
|
8
|
+
assert_equal '/etc/dnsmasq.d/foreman.conf', Proxy::Dns::Dnsmasq::Plugin.settings[:config_path]
|
9
|
+
assert_equal 'systemctl restart dnsmasq', Proxy::Dns::Dnsmasq::Plugin.settings[:reload_cmd]
|
10
10
|
end
|
11
11
|
end
|
@@ -9,7 +9,8 @@ class DnsDnsmasqProductionWiringTest < Test::Unit::TestCase
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def test_dns_provider_initialization_default
|
12
|
-
@config.load_dependency_injection_wirings(@container,
|
12
|
+
@config.load_dependency_injection_wirings(@container,
|
13
|
+
:dns_ttl => 999,
|
13
14
|
:config_path => '/etc/dnsmasq.conf',
|
14
15
|
:reload_cmd => 'systemctl reload dnsmasq')
|
15
16
|
|
@@ -23,7 +24,8 @@ class DnsDnsmasqProductionWiringTest < Test::Unit::TestCase
|
|
23
24
|
end
|
24
25
|
|
25
26
|
def test_dns_provider_initialization
|
26
|
-
@config.load_dependency_injection_wirings(@container,
|
27
|
+
@config.load_dependency_injection_wirings(@container,
|
28
|
+
:dns_ttl => 999,
|
27
29
|
:backend => 'openwrt',
|
28
30
|
:config_path => '/etc/config/dhcp',
|
29
31
|
:reload_cmd => '/etc/init.d/dnsmasq reload')
|
@@ -18,8 +18,8 @@ class DnsDnsmasqRecordDefaultTest < Test::Unit::TestCase
|
|
18
18
|
|
19
19
|
@configuration.expects(:<<).with { |val|
|
20
20
|
val.is_a?(Proxy::Dns::Dnsmasq::Default::AddressEntry) &&
|
21
|
-
|
22
|
-
|
21
|
+
val.fqdn == [fqdn] &&
|
22
|
+
val.ip == ip
|
23
23
|
}.returns(true)
|
24
24
|
assert @provider.do_create(fqdn, ip, 'A')
|
25
25
|
end
|
@@ -31,8 +31,8 @@ class DnsDnsmasqRecordDefaultTest < Test::Unit::TestCase
|
|
31
31
|
|
32
32
|
@configuration.expects(:<<).with { |val|
|
33
33
|
val.is_a?(Proxy::Dns::Dnsmasq::Default::AddressEntry) &&
|
34
|
-
|
35
|
-
|
34
|
+
val.fqdn == [fqdn] &&
|
35
|
+
val.ip == ip
|
36
36
|
}.returns(true)
|
37
37
|
assert @provider.do_create(fqdn, ip, 'AAAA')
|
38
38
|
end
|
@@ -44,8 +44,8 @@ class DnsDnsmasqRecordDefaultTest < Test::Unit::TestCase
|
|
44
44
|
|
45
45
|
@configuration.expects(:<<).with { |val|
|
46
46
|
val.is_a?(Proxy::Dns::Dnsmasq::Default::PTREntry) &&
|
47
|
-
|
48
|
-
|
47
|
+
val.fqdn == fqdn &&
|
48
|
+
val.ip == ip
|
49
49
|
}.returns(true)
|
50
50
|
assert @provider.do_create(ip, fqdn, 'PTR')
|
51
51
|
end
|
@@ -57,8 +57,8 @@ class DnsDnsmasqRecordDefaultTest < Test::Unit::TestCase
|
|
57
57
|
|
58
58
|
@configuration.expects(:<<).with { |val|
|
59
59
|
val.is_a?(Proxy::Dns::Dnsmasq::Default::PTREntry) &&
|
60
|
-
|
61
|
-
|
60
|
+
val.fqdn == fqdn &&
|
61
|
+
val.ip == ip
|
62
62
|
}.returns(true)
|
63
63
|
assert @provider.do_create(ip, fqdn, 'PTR')
|
64
64
|
end
|
@@ -71,8 +71,8 @@ class DnsDnsmasqRecordDefaultTest < Test::Unit::TestCase
|
|
71
71
|
@configuration.expects(:find).returns(nil)
|
72
72
|
@configuration.expects(:<<).with { |val|
|
73
73
|
val.is_a?(Proxy::Dns::Dnsmasq::Default::CNAMEEntry) &&
|
74
|
-
|
75
|
-
|
74
|
+
val.name == name &&
|
75
|
+
val.target == target
|
76
76
|
}.returns(true)
|
77
77
|
assert @provider.do_create(name, target, 'CNAME')
|
78
78
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_proxy_dns_dnsmasq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.6'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Olofsson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -96,14 +96,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
96
|
version: '0'
|
97
97
|
requirements: []
|
98
98
|
rubyforge_project:
|
99
|
-
rubygems_version: 2.6.
|
99
|
+
rubygems_version: 2.6.12
|
100
100
|
signing_key:
|
101
101
|
specification_version: 4
|
102
102
|
summary: dnsmasq DNS provider plugin for Foreman's smart proxy
|
103
103
|
test_files:
|
104
|
-
- test/test_helper.rb
|
105
|
-
- test/dns_dnsmasq_default_settings_test.rb
|
106
104
|
- test/dns_dnsmasq_production_wiring_test.rb
|
107
|
-
- test/testdata.openwrt
|
108
|
-
- test/dns_dnsmasq_record_openwrt_test.rb
|
109
105
|
- test/dns_dnsmasq_record_default_test.rb
|
106
|
+
- test/dns_dnsmasq_record_openwrt_test.rb
|
107
|
+
- test/test_helper.rb
|
108
|
+
- test/testdata.openwrt
|
109
|
+
- test/dns_dnsmasq_default_settings_test.rb
|