smart_proxy_dns_dnsmasq 0.5 → 0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eb1aac2f3d95b7d541050735d2459b4c32a95331
4
- data.tar.gz: f4fb0328e7cbf48f03d6ea70533e92c5e237a705
3
+ metadata.gz: 50d4032f443de747d784de78eb8bbf0ca97b236a
4
+ data.tar.gz: 88ec43f74a5c58deac1d4d41b53cf6c08e848c27
5
5
  SHA512:
6
- metadata.gz: ad7db5669dd48e3d3826597d45048783766d82d5826b2c17366bc65e15bd0885063346557a910da33b500d8456760fb71b41ba6f20d40337947f621b62262810
7
- data.tar.gz: 2e3bc42987949e4fce223869f7e286fdc94a227d64f9326bd0a49dd2d6a6d3d316f1f76ba2d5cdb4c952431ed6f84257969ddc93e4372e19bbe6a2016272c27c
6
+ metadata.gz: 4ae2ab7e58dd195c8b66663f61d7abba7ca0ee2567ecd0371935855bef256b0ae57ecfd005dd9984551351556f864ac8b40b09f1a32807ab456095c1ca5040fb
7
+ data.tar.gz: 38a647b8bec5943708698dbc127f5f6e1d5cc88972bd34c3e4e7341e86cbe4580a8f24f97aeaa9998d49ec8fecbb79857363638356ae7d01b50f675e09194e3a
@@ -6,4 +6,4 @@
6
6
  #
7
7
  #:backend: default
8
8
  :config_path: /etc/dnsmasq.d/foreman.conf
9
- :reload_cmd: systemctl reload dnsmasq
9
+ :reload_cmd: systemctl restart dnsmasq
@@ -35,12 +35,13 @@ module Proxy::Dns::Dnsmasq
35
35
  end
36
36
 
37
37
  def remove_entry(type, fqdn = nil, ip = nil)
38
- return true unless case type
39
- when 'A', 'AAAA'
40
- e = configuration.find { |entry| entry.is_a?(AddressEntry) && entry.fqdn.include?(fqdn) }
41
- when 'PTR'
42
- e = configuration.find { |entry| entry.is_a?(PTREntry) && entry.ip == ip }
43
- end
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.shift
99
- entry.fqdn = data.shift
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 = [ 'openwrt', 'default' ].freeze
8
+ BACKENDS = %i(openwrt default).freeze
9
9
  def load_dependency_injection_wirings(container_instance, settings)
10
- backend = settings[:backend] || 'default'
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, 'In'
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 backend #{backend}: #{e}"
20
+ raise ::Proxy::Error::ConfigurationError, e, "Failed to load #{backend} backend"
20
21
  end
21
22
 
22
23
  klass = case backend
23
- when 'openwrt'
24
- ::Proxy::Dns::Dnsmasq::Openwrt
25
- when 'default'
26
- ::Proxy::Dns::Dnsmasq::Default
27
- end
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
- settings[:config_path],
32
- settings[:reload_cmd],
33
- settings[:dns_ttl])
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 => 'systemctl reload dnsmasq'
12
+ :reload_cmd => 'systemctl restart dnsmasq'
13
13
 
14
14
  requires :dns, '>= 1.15'
15
15
 
@@ -1,7 +1,7 @@
1
1
  module Proxy
2
2
  module Dns
3
3
  module Dnsmasq
4
- VERSION = '0.5'
4
+ VERSION = '0.6'.freeze
5
5
  end
6
6
  end
7
7
  end
@@ -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 "default_value", Proxy::Dns::Dnsmasq::Plugin.settings.required_setting
9
- assert_equal "/must/exist", Proxy::Dns::Dnsmasq::Plugin.settings.required_path
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, :dns_ttl => 999,
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, :dns_ttl => 999,
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
- val.fqdn == [fqdn] &&
22
- val.ip == ip
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
- val.fqdn == [fqdn] &&
35
- val.ip == ip
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
- val.fqdn == fqdn &&
48
- val.ip == ip
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
- val.fqdn == fqdn &&
61
- val.ip == ip
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
- val.name == name &&
75
- val.target == target
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.5'
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-03-17 00:00:00.000000000 Z
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.8
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