dns_one 0.4.28 → 0.4.29
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 -0
- data/lib/dns_one.rb +1 -0
- data/lib/dns_one/cli.rb +13 -0
- data/lib/dns_one/server.rb +24 -11
- data/lib/dns_one/version.rb +1 -1
- data/lib/dns_one/zone_search.rb +7 -4
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ad077556ec78e89b5d4f8a88827dc77bf8397e8
|
4
|
+
data.tar.gz: 8b7916cd71ad40672f8fca7a5baf41b13129c2a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc2559f45f107f09ffcf56579890d057104ca176e8c27e9737a793ef754ac2b0a732dd1a84fe324e4b6d8e663c6d5e32426961b631fe92db24233acf9e81fb9a
|
7
|
+
data.tar.gz: 51fe6c09207f7026008300afade6e95675ea93b79d7d2b7506eb1bdba85eee7ad82372ef4edc5b7a82ecb14507a4326c62920a86a8118bf8aba51042a5a14879
|
data/dns_one.gemspec
CHANGED
data/lib/dns_one.rb
CHANGED
data/lib/dns_one/cli.rb
CHANGED
@@ -2,6 +2,7 @@ require "thor"
|
|
2
2
|
|
3
3
|
require "dns_one"
|
4
4
|
require "dns_one/setup"
|
5
|
+
require 'sqlite3'
|
5
6
|
|
6
7
|
class DnsOne::CLI < Thor
|
7
8
|
|
@@ -52,4 +53,16 @@ class DnsOne::CLI < Thor
|
|
52
53
|
DnsOne::Util.ensure_sytemd
|
53
54
|
DnsOne::Util.run "systemctl status #{DnsOne::Setup::SERVICE_NAME}"
|
54
55
|
end
|
56
|
+
|
57
|
+
# STATS
|
58
|
+
|
59
|
+
desc "stats", "show counters"
|
60
|
+
def stats
|
61
|
+
stat = DnsOne::Stat.new(db_file: 'stat.db')
|
62
|
+
[
|
63
|
+
stat.get_counts(:rcode),
|
64
|
+
stat.get_counts(:req_resource),
|
65
|
+
stat.get_counts(:cache)
|
66
|
+
]
|
67
|
+
end
|
55
68
|
end
|
data/lib/dns_one/server.rb
CHANGED
@@ -15,11 +15,13 @@ module DnsOne; class Server
|
|
15
15
|
def initialize conf, conf_zone_search
|
16
16
|
@conf = conf
|
17
17
|
@zone_search = ZoneSearch.instance.setup conf_zone_search
|
18
|
+
@stat = Stat.new(db_file: 'stat.db')
|
18
19
|
end
|
19
20
|
|
20
21
|
def run
|
21
22
|
zone_search = @zone_search
|
22
23
|
conf = @conf
|
24
|
+
stat = @stat
|
23
25
|
|
24
26
|
RubyDNS::run_server(listen: dns_daemon_interfaces, logger: Log.logger) do
|
25
27
|
on(:start) do
|
@@ -31,22 +33,33 @@ module DnsOne; class Server
|
|
31
33
|
end
|
32
34
|
|
33
35
|
match(/(.+)/) do |t| # transaction
|
34
|
-
|
35
|
-
ip_address = t.options[:peer] rescue nil
|
36
|
+
rcode = :NoError
|
36
37
|
|
37
|
-
|
38
|
+
begin
|
39
|
+
domain_name = t.question.to_s
|
40
|
+
ip_address = t.options[:peer] rescue nil
|
38
41
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
records, from_cache = zone_search.query domain_name, t.resource_class, ip_address
|
43
|
+
|
44
|
+
if records
|
45
|
+
if records.empty?
|
46
|
+
t.fail! :NoError
|
47
|
+
else
|
48
|
+
records.each do |rec|
|
49
|
+
t.respond! *[rec.val].flatten, {resource_class: rec.res_class, section: rec.section}
|
50
|
+
end
|
45
51
|
end
|
52
|
+
else
|
53
|
+
rcode = :NXDomain
|
54
|
+
t.fail! :NXDomain
|
46
55
|
end
|
47
|
-
|
48
|
-
|
56
|
+
rescue => e
|
57
|
+
rcode = :ServFail
|
49
58
|
end
|
59
|
+
|
60
|
+
stat.save rcode, t.resource_class, from_cache
|
61
|
+
|
62
|
+
raise e if e
|
50
63
|
end
|
51
64
|
|
52
65
|
otherwise do |t|
|
data/lib/dns_one/version.rb
CHANGED
data/lib/dns_one/zone_search.rb
CHANGED
@@ -32,7 +32,7 @@ module DnsOne; class ZoneSearch
|
|
32
32
|
|
33
33
|
records = []
|
34
34
|
|
35
|
-
rec_set_name = find_record_set dom_name
|
35
|
+
rec_set_name, from_cache = find_record_set dom_name
|
36
36
|
Log.d "domain #{ rec_set_name ? "found, rec_set_name = '#{rec_set_name}'" : 'not found' }"
|
37
37
|
return unless rec_set_name
|
38
38
|
|
@@ -64,7 +64,7 @@ module DnsOne; class ZoneSearch
|
|
64
64
|
records << OpenStruct.new(val: val, res_class: res_class, section: 'answer')
|
65
65
|
end
|
66
66
|
|
67
|
-
records
|
67
|
+
[records, from_cache]
|
68
68
|
end
|
69
69
|
|
70
70
|
private
|
@@ -102,15 +102,18 @@ module DnsOne; class ZoneSearch
|
|
102
102
|
|
103
103
|
enabled_cache = use_cache && @backend.allow_cache
|
104
104
|
|
105
|
+
from_cache = false
|
106
|
+
|
105
107
|
if enabled_cache and rec_set = @cache.find(dom_name)
|
106
108
|
Log.d "found in cache (#{@cache.stat})"
|
107
|
-
|
109
|
+
from_cache = true
|
110
|
+
[rec_set, from_cache]
|
108
111
|
else
|
109
112
|
if rec_set = @backend.find(dom_name)
|
110
113
|
if enabled_cache
|
111
114
|
@cache.add dom_name, rec_set
|
112
115
|
end
|
113
|
-
rec_set
|
116
|
+
[rec_set, from_cache]
|
114
117
|
end
|
115
118
|
end
|
116
119
|
end
|
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.29
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Lobato
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '5.0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: sqlite3
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '1.3'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '1.3'
|
125
139
|
description: Instead having a complex data schema to assign record sets to DNS zones,
|
126
140
|
dns_one assigns one or a few record sets to many zones. Configure your record sets
|
127
141
|
in YML files and fetch your domains from a database or YML backend.
|