smart_proxy_dhcp_dnsmasq 0.6 → 0.7
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 +5 -5
- data/bundler.d/dhcp_dnsmasq.rb +1 -0
- data/lib/smart_proxy_dhcp_dnsmasq/dhcp_dnsmasq_main.rb +16 -1
- data/lib/smart_proxy_dhcp_dnsmasq/dhcp_dnsmasq_subnet_service.rb +6 -11
- data/lib/smart_proxy_dhcp_dnsmasq/dhcp_dnsmasq_version.rb +1 -1
- data/test/dhcp_dnsmasq_production_wiring_test.rb +1 -0
- data/test/dhcp_dnsmasq_record_handling_test.rb +1 -0
- data/test/dhcp_dnsmasq_subnet_service_test.rb +2 -2
- metadata +6 -7
- data/bundler.d/dns_dnsmasq.rb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b9f60a51d51d8a80edf7ebd7f841ef4f5e44397c4b86bfb5c13c8872fab3d74b
|
4
|
+
data.tar.gz: e528fe5bc8aef7b939ab6feea332ec2c0aedba81d5a101e2be1d063c242fb2b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45ba84592849d76efe6725ec24723509ac3347d7a4ff15c1de47969aeb3cd5a9e019d51521b2bdddca27ff7bb25c861fd49ff6c17261a08cc1be60066099cd0c
|
7
|
+
data.tar.gz: 9d7e177853adff920b1c98892c4a240c174afdb7ff07e848ec49065434f2f59ca9e7df890cc4a2fdcfdb7e0b426dfa09417a960986f12a8b8b66e40400a94c62
|
@@ -0,0 +1 @@
|
|
1
|
+
gem 'smart_proxy_dhcp_dnsmasq'
|
@@ -13,6 +13,7 @@ module Proxy::DHCP::Dnsmasq
|
|
13
13
|
@optsfile_content = []
|
14
14
|
|
15
15
|
Dir.mkdir @config_dir unless Dir.exist? @config_dir
|
16
|
+
cleanup_optsfile if true # TODO: Only cleanup occasionally
|
16
17
|
|
17
18
|
subnet_service.load!
|
18
19
|
|
@@ -72,7 +73,7 @@ module Proxy::DHCP::Dnsmasq
|
|
72
73
|
def optsfile_content
|
73
74
|
path = File.join(@config_dir, 'dhcpopts.conf').freeze
|
74
75
|
|
75
|
-
@optsfile_content = open(path).readlines \
|
76
|
+
@optsfile_content = File.open(path).readlines.map(&:chomp).reject(&:empty?) \
|
76
77
|
if File.exist?(path) && @optsfile_content.empty?
|
77
78
|
@optsfile_content
|
78
79
|
end
|
@@ -85,6 +86,20 @@ module Proxy::DHCP::Dnsmasq
|
|
85
86
|
File.write(path, optsfile_content.join("\n") + "\n")
|
86
87
|
end
|
87
88
|
|
89
|
+
def cleanup_optsfile
|
90
|
+
used_tags = []
|
91
|
+
Dir.glob(File.join(@config_dir, 'dhcphosts', '*.conf')) do |file|
|
92
|
+
File.read(file).scan(/set:(.*?),/m) { |tag| used_tags << tag }
|
93
|
+
end
|
94
|
+
used_tags = used_tags.sort.uniq
|
95
|
+
|
96
|
+
@optsfile_content = optsfile_content.select do |line|
|
97
|
+
tag = line[/tag:(.*?),/, 1]
|
98
|
+
used_tags.include?(tag)
|
99
|
+
end
|
100
|
+
File.write(File.join(@config_dir, 'dhcpopts.conf'), optsfile_content.join("\n") + "\n")
|
101
|
+
end
|
102
|
+
|
88
103
|
def sanitize_string(string)
|
89
104
|
string.downcase.gsub(/[^0-9a-z]/, '_')
|
90
105
|
end
|
@@ -43,7 +43,7 @@ module Proxy::DHCP::Dnsmasq
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def parse_config_for_subnet
|
46
|
-
configuration = {}
|
46
|
+
configuration = { options: {} }
|
47
47
|
files = []
|
48
48
|
@config_paths.each do |path|
|
49
49
|
files << path if File.exist? path
|
@@ -88,8 +88,6 @@ module Proxy::DHCP::Dnsmasq
|
|
88
88
|
when 'dhcp-option'
|
89
89
|
data = value.split(',')
|
90
90
|
|
91
|
-
configuration[:options] = {} unless configuration.key? :options
|
92
|
-
|
93
91
|
data.shift until data.empty? || /\A\d+\z/ === data.first
|
94
92
|
next if data.empty?
|
95
93
|
|
@@ -217,27 +215,24 @@ module Proxy::DHCP::Dnsmasq
|
|
217
215
|
if dupe = find_host_by_mac(record.subnet_address, record.mac)
|
218
216
|
logger.debug "Found duplicate #{dupe} when adding record #{record}, skipping"
|
219
217
|
next
|
220
|
-
# delete_host(dupe)
|
221
218
|
end
|
222
219
|
|
223
|
-
logger.debug "Adding host #{record}"
|
220
|
+
# logger.debug "Adding host #{record}"
|
224
221
|
add_host(record.subnet_address, record)
|
225
222
|
end
|
226
223
|
|
227
|
-
leases =
|
224
|
+
leases = load_leases
|
228
225
|
leases.each do |lease|
|
229
226
|
if dupe = find_lease_by_mac(lease.subnet_address, lease.mac)
|
230
|
-
logger.debug "
|
227
|
+
logger.debug "Found duplicate #{dupe} by MAC when adding lease #{lease}, skipping"
|
231
228
|
next
|
232
|
-
# delete_lease(dupe)
|
233
229
|
end
|
234
230
|
if dupe = find_lease_by_ip(lease.subnet_address, lease.ip)
|
235
|
-
logger.debug "
|
231
|
+
logger.debug "Found duplicate #{dupe} by IP when adding lease #{lease}, skipping"
|
236
232
|
next
|
237
|
-
# delete_lease(dupe)
|
238
233
|
end
|
239
234
|
|
240
|
-
logger.debug "Adding lease #{lease}"
|
235
|
+
# logger.debug "Adding lease #{lease}"
|
241
236
|
add_lease(lease.subnet_address, lease)
|
242
237
|
end
|
243
238
|
end
|
@@ -6,6 +6,7 @@ class DHCPDnsmasqProductionWiringTest < Test::Unit::TestCase
|
|
6
6
|
def setup
|
7
7
|
@container = ::Proxy::DependencyInjection::Container.new
|
8
8
|
@config = ::Proxy::DHCP::Dnsmasq::PluginConfiguration.new
|
9
|
+
Proxy::DHCP::Dnsmasq::Record.any_instance.stubs(:cleanup_optsfile)
|
9
10
|
end
|
10
11
|
|
11
12
|
def test_dns_provider_initialization_default
|
@@ -6,6 +6,7 @@ class DHCPDnsmasqRecordHandlingTest < Test::Unit::TestCase
|
|
6
6
|
@subnet_service = mock
|
7
7
|
@subnet_service.expects(:load!).returns(true)
|
8
8
|
Dir.stubs(:exist?).returns(true)
|
9
|
+
Proxy::DHCP::Dnsmasq::Record.any_instance.stubs(:cleanup_optsfile)
|
9
10
|
|
10
11
|
@server = ::Proxy::DHCP::Dnsmasq::Record.new('/etc/dnsmasq.d/', '/bin/true', @subnet_service)
|
11
12
|
@server.instance_eval('@optsfile_content = []')
|
@@ -21,11 +21,11 @@ class DHCPDnsmasqSubnetServiceTest < Test::Unit::TestCase
|
|
21
21
|
|
22
22
|
initializer.expects(:add_subnet).with(subnet)
|
23
23
|
initializer.expects(:add_host)
|
24
|
-
|
24
|
+
initializer.expects(:add_lease)
|
25
25
|
|
26
26
|
initializer.expects(:parse_config_for_subnet).returns(subnet)
|
27
27
|
initializer.expects(:parse_config_for_dhcp_reservations).returns([host])
|
28
|
-
|
28
|
+
initializer.expects(:load_leases).returns([lease])
|
29
29
|
# initializer.expects(:add_watch)
|
30
30
|
|
31
31
|
initializer.load!
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_proxy_dhcp_dnsmasq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.7'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Olofsson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -61,7 +61,7 @@ extra_rdoc_files: []
|
|
61
61
|
files:
|
62
62
|
- LICENSE
|
63
63
|
- README.md
|
64
|
-
- bundler.d/
|
64
|
+
- bundler.d/dhcp_dnsmasq.rb
|
65
65
|
- config/dhcp_dnsmasq.yml
|
66
66
|
- lib/smart_proxy_dhcp_dnsmasq.rb
|
67
67
|
- lib/smart_proxy_dhcp_dnsmasq/dhcp_dnsmasq_configuration.rb
|
@@ -74,7 +74,7 @@ files:
|
|
74
74
|
- test/dhcp_dnsmasq_record_handling_test.rb
|
75
75
|
- test/dhcp_dnsmasq_subnet_service_test.rb
|
76
76
|
- test/test_helper.rb
|
77
|
-
homepage: https://github.com/
|
77
|
+
homepage: https://github.com/theforeman/smart_proxy_dhcp_dnsmasq
|
78
78
|
licenses:
|
79
79
|
- GPL-3.0
|
80
80
|
metadata: {}
|
@@ -93,14 +93,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '0'
|
95
95
|
requirements: []
|
96
|
-
|
97
|
-
rubygems_version: 2.6.12
|
96
|
+
rubygems_version: 3.0.3
|
98
97
|
signing_key:
|
99
98
|
specification_version: 4
|
100
99
|
summary: dnsmasq DHCP provider plugin for Foreman's smart proxy
|
101
100
|
test_files:
|
102
101
|
- test/test_helper.rb
|
102
|
+
- test/dhcp_dnsmasq_subnet_service_test.rb
|
103
103
|
- test/dhcp_dnsmasq_default_settings_test.rb
|
104
104
|
- test/dhcp_dnsmasq_production_wiring_test.rb
|
105
105
|
- test/dhcp_dnsmasq_record_handling_test.rb
|
106
|
-
- test/dhcp_dnsmasq_subnet_service_test.rb
|
data/bundler.d/dns_dnsmasq.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
gem 'smart_proxy_dns_dnsmasq'
|