dns_one 0.4.13 → 0.4.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dns_one.gemspec +1 -2
- data/lib/dns_one.rb +8 -6
- data/lib/dns_one/backend/db.rb +6 -7
- data/lib/dns_one/core_ext/blank.rb +2 -4
- data/lib/dns_one/server.rb +2 -5
- data/lib/dns_one/version.rb +1 -1
- data/lib/dns_one/zone_search.rb +12 -7
- metadata +4 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50cf0e24bbf380a428f8409061da2bc49087d2e4
|
4
|
+
data.tar.gz: 39660c4fb96db37f8f1d392a35860ed7a5c571ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3726f0e434e47ec467ee7f3e777faca6fe7826c74eec36c4aa8b43b7b0c0209abeac38bf3b224b35f7aea0818193ed80a913068449021bcddff49468ca4bfa73
|
7
|
+
data.tar.gz: 78aaeca54c29ae2a8824b9fa7ad426cc766a242cf4837d4f72afb293cc147b2fef71658eebee5136fa5ae54df9644f87be45ac28245c9c27885740fe6c4da723
|
data/dns_one.gemspec
CHANGED
@@ -25,9 +25,8 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
26
|
spec.add_development_dependency "rspec", "~> 3.0"
|
27
27
|
|
28
|
-
spec.add_runtime_dependency "thor", '~> 0.19
|
28
|
+
spec.add_runtime_dependency "thor", '~> 0.19'
|
29
29
|
spec.add_runtime_dependency "rubydns", '~> 1.0'
|
30
|
-
spec.add_runtime_dependency "activerecord", '~> 5.1'
|
31
30
|
spec.add_runtime_dependency "rexec", '~> 1.6'
|
32
31
|
|
33
32
|
end
|
data/lib/dns_one.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# Core
|
2
2
|
require 'syslog'
|
3
3
|
require 'syslog/logger'
|
4
|
+
require 'ostruct'
|
5
|
+
require 'yaml'
|
6
|
+
require 'singleton'
|
4
7
|
|
5
8
|
# Gems
|
6
|
-
require 'rubydns'
|
7
|
-
require 'active_record'
|
8
|
-
require 'yaml'
|
9
9
|
require 'rexec'
|
10
|
-
require '
|
10
|
+
require 'rubydns'
|
11
11
|
|
12
12
|
# DnsOne
|
13
13
|
|
@@ -67,12 +67,14 @@ module DnsOne; class DnsOne
|
|
67
67
|
end
|
68
68
|
|
69
69
|
private
|
70
|
-
|
70
|
+
def symbolize_keys(hash)
|
71
|
+
hash.each_with_object({}) { |(k, v), h| h[k.to_sym] = v.is_a?(Hash) ? symbolize_keys(v) : v }
|
72
|
+
end
|
71
73
|
def parse_conf conf_file
|
72
74
|
check_conf_file conf_file
|
73
75
|
|
74
76
|
conf = YAML.load_file conf_file
|
75
|
-
conf
|
77
|
+
conf = symbolize_keys conf
|
76
78
|
|
77
79
|
OpenStruct.new(
|
78
80
|
main: {
|
data/lib/dns_one/backend/db.rb
CHANGED
@@ -55,13 +55,12 @@ module Backend; class BackendDB
|
|
55
55
|
Util.die "Database adapter '#{@conf[:adapter]}' not supported. Aborting."
|
56
56
|
end
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
Util.die "Error loading database dependency.\n#{e.desc}"
|
58
|
+
['active_record', gem_name].each do |req_name|
|
59
|
+
begin
|
60
|
+
require req_name
|
61
|
+
rescue => e
|
62
|
+
Util.die "Error on 'require #{req_name}', install with 'gem install #{req_name}'.\nError Details: #{e.desc}"
|
63
|
+
end
|
65
64
|
end
|
66
65
|
|
67
66
|
ActiveRecord::Base.establish_connection @conf
|
@@ -112,9 +112,7 @@ class Hash
|
|
112
112
|
end
|
113
113
|
|
114
114
|
class String
|
115
|
-
|
116
|
-
BLANK_RE = /\A[[:space:]]*\z/
|
117
|
-
end
|
115
|
+
LOCAL_BLANK_RE = /\A[[:space:]]*\z/
|
118
116
|
|
119
117
|
# A string is blank if it's empty or contains whitespaces only:
|
120
118
|
#
|
@@ -132,7 +130,7 @@ class String
|
|
132
130
|
# The regexp that matches blank strings is expensive. For the case of empty
|
133
131
|
# strings we can speed up this method (~3.5x) with an empty? call. The
|
134
132
|
# penalty for the rest of strings is marginal.
|
135
|
-
empty? ||
|
133
|
+
empty? || LOCAL_BLANK_RE.match?(self)
|
136
134
|
end
|
137
135
|
end
|
138
136
|
|
data/lib/dns_one/server.rb
CHANGED
@@ -12,15 +12,12 @@ module DnsOne; class Server # < RExec::Daemon::Base
|
|
12
12
|
|
13
13
|
def initialize conf, conf_zone_search
|
14
14
|
@conf = conf
|
15
|
-
ZoneSearch.instance.setup conf_zone_search
|
15
|
+
@zone_search = ZoneSearch.instance.setup conf_zone_search
|
16
16
|
end
|
17
17
|
|
18
18
|
def run
|
19
|
+
zone_search = @zone_search
|
19
20
|
conf = @conf
|
20
|
-
zone_search = ZoneSearch.instance
|
21
|
-
|
22
|
-
# Find a dummy zone to make AR/pg load all dependencies
|
23
|
-
zone_search.query 'dummy.com.br', Resolv::DNS::Resource::IN, '1.2.3.4'
|
24
21
|
|
25
22
|
RubyDNS::run_server(listen: dns_daemon_interfaces, logger: Log.logger) do
|
26
23
|
on(:start) do
|
data/lib/dns_one/version.rb
CHANGED
data/lib/dns_one/zone_search.rb
CHANGED
@@ -10,14 +10,12 @@ module DnsOne; class ZoneSearch
|
|
10
10
|
check_record_sets
|
11
11
|
@backend = set_backend
|
12
12
|
@cache = Cache.new @conf[:cache_max]
|
13
|
+
@ignore_subdomains_re = build_ignore_subdomains_re
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
@ignore_subdomains_re = /^(#{ subdoms })\./i
|
19
|
-
end
|
20
|
-
end
|
15
|
+
# Find a dummy zone to make AR/pg load all dependencies
|
16
|
+
query 'dummy.com.br', Resolv::DNS::Resource::IN, '1.2.3.4'
|
17
|
+
|
18
|
+
self
|
21
19
|
end
|
22
20
|
|
23
21
|
def query dom_name, res_class, ip_address
|
@@ -63,6 +61,13 @@ module DnsOne; class ZoneSearch
|
|
63
61
|
|
64
62
|
private
|
65
63
|
|
64
|
+
def build_ignore_subdomains_re
|
65
|
+
if i = @conf[:ignore_subdomains].presence
|
66
|
+
s = i.strip.split(/\s+/).map(&:downcase).join '|'
|
67
|
+
/^(#{ s })\./i
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
66
71
|
def set_backend
|
67
72
|
if file = @conf[:backend][:file]
|
68
73
|
unless File.exists? file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dns_one
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Lobato
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.19
|
61
|
+
version: '0.19'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.19
|
68
|
+
version: '0.19'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rubydns
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,20 +80,6 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '1.0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: activerecord
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '5.1'
|
90
|
-
type: :runtime
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '5.1'
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
84
|
name: rexec
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|