dns_one 0.4.58 → 0.4.59
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 +4 -4
- data/lib/dns_one/server.rb +54 -0
- data/lib/dns_one/version.rb +1 -1
- data/lib/dns_one.rb +4 -3
- data/util/sample_conf.yml +2 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9f7aff37d7886eb30db71113afa0e7eb6fe5bb8a
|
|
4
|
+
data.tar.gz: 896af67a899b60acde6bc43a71a5830ccdeed3bf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bdb9fd6536e5a3a808320e6fc56481e77610a0838852e0d3bc14cb0f65d5acf78b3dc224b1dcf7c3fb307e28a05a6bf31d8a09863513e3f9ceed69096907d8a3
|
|
7
|
+
data.tar.gz: cb5f9daf3bfd0fc324662239587bd7fab045b3f781559f7b413d059e99ed2dda9f719ddea20ca2b1b5f4f8501d126485fc16290ddfd8f626dee673ad55ff675f
|
data/lib/dns_one/server.rb
CHANGED
|
@@ -4,6 +4,7 @@ require "dns_one/zone_search"
|
|
|
4
4
|
module DnsOne; class Server
|
|
5
5
|
|
|
6
6
|
DEFAULT_RUN_AS = "dnsone"
|
|
7
|
+
DEFAULT_LOG_RESULT_SOCKET_FILE = '/tmp/dns_one_log_result.sock'
|
|
7
8
|
|
|
8
9
|
DNS_DAEMON_INTERFACES = [
|
|
9
10
|
[:udp, "0.0.0.0", 53],
|
|
@@ -15,12 +16,20 @@ module DnsOne; class Server
|
|
|
15
16
|
def initialize conf, conf_zone_search
|
|
16
17
|
@conf = conf
|
|
17
18
|
@zone_search = ZoneSearch.instance.setup conf_zone_search
|
|
19
|
+
if conf[:log_result_socket]
|
|
20
|
+
@log_result_mutex = Mutex.new
|
|
21
|
+
launch_log_result_socket
|
|
22
|
+
end
|
|
18
23
|
end
|
|
19
24
|
|
|
20
25
|
def run
|
|
21
26
|
zone_search = @zone_search
|
|
22
27
|
conf = @conf
|
|
23
28
|
stat = nil
|
|
29
|
+
if conf[:log_result_socket]
|
|
30
|
+
log_result = @log_result
|
|
31
|
+
log_result_mutex = @log_result_mutex
|
|
32
|
+
end
|
|
24
33
|
|
|
25
34
|
RubyDNS::run_server(listen: dns_daemon_interfaces, logger: Log.ruby_dns_logger) do
|
|
26
35
|
on(:start) do
|
|
@@ -69,6 +78,25 @@ module DnsOne; class Server
|
|
|
69
78
|
Util.log_result ip_address, domain_name, t.resource_class, rcode, resp_log, from_cache
|
|
70
79
|
end
|
|
71
80
|
|
|
81
|
+
if conf[:log_result_socket]
|
|
82
|
+
log_result_mutex.synchronize {
|
|
83
|
+
log_result[:requests] ||= 0
|
|
84
|
+
log_result[:requests] += 1
|
|
85
|
+
|
|
86
|
+
log_result[:cache] ||= 0
|
|
87
|
+
log_result[:cache] += 1 if from_cache
|
|
88
|
+
|
|
89
|
+
log_result[:rcode] ||= {}
|
|
90
|
+
log_result[:rcode][rcode] ||= 0
|
|
91
|
+
log_result[:rcode][rcode] += 1
|
|
92
|
+
|
|
93
|
+
req_resource = Util.last_mod t.resource_class
|
|
94
|
+
log_result[:req_resource] ||= {}
|
|
95
|
+
log_result[:req_resource][req_resource] ||= 0
|
|
96
|
+
log_result[:req_resource][req_resource] += 1
|
|
97
|
+
}
|
|
98
|
+
end
|
|
99
|
+
|
|
72
100
|
raise e if e
|
|
73
101
|
end
|
|
74
102
|
|
|
@@ -93,4 +121,30 @@ module DnsOne; class Server
|
|
|
93
121
|
end
|
|
94
122
|
end
|
|
95
123
|
|
|
124
|
+
def launch_log_result_socket
|
|
125
|
+
log_result = @log_result
|
|
126
|
+
log_result_mutex = @log_result_mutex
|
|
127
|
+
sock = Thread.new do
|
|
128
|
+
Socket.unix_server_loop(conf[:log_result_socket_file] || DEFAULT_LOG_RESULT_SOCKET_FILE) do |sock, addr|
|
|
129
|
+
Log.i "opened unix socket #{sock}"
|
|
130
|
+
Thread.new do
|
|
131
|
+
loop do
|
|
132
|
+
begin
|
|
133
|
+
log_result_mutex.synchronize {
|
|
134
|
+
sock.write "#{ log_result.to_json }\n"
|
|
135
|
+
}
|
|
136
|
+
rescue Errno::EPIPE => e
|
|
137
|
+
break
|
|
138
|
+
rescue => e
|
|
139
|
+
Log.e e
|
|
140
|
+
break
|
|
141
|
+
end
|
|
142
|
+
Thread.pass
|
|
143
|
+
sleep 0.1
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
96
150
|
end; end
|
data/lib/dns_one/version.rb
CHANGED
data/lib/dns_one.rb
CHANGED
|
@@ -64,9 +64,10 @@ module DnsOne; class DnsOne
|
|
|
64
64
|
work_dir: conf[:config][:work_dir]
|
|
65
65
|
},
|
|
66
66
|
server: {
|
|
67
|
-
run_as:
|
|
68
|
-
log_results:
|
|
69
|
-
save_stats:
|
|
67
|
+
run_as: conf[:config][:run_as],
|
|
68
|
+
log_results: (conf[:config][:log_results] == '1'),
|
|
69
|
+
save_stats: (conf[:config][:save_stats] == '1'),
|
|
70
|
+
log_result_socket_file: (conf[:config][:log_result_socket_file] == '1')
|
|
70
71
|
},
|
|
71
72
|
zone_search: {
|
|
72
73
|
ignore_subdomains: conf[:config][:ignore_subdomains],
|
data/util/sample_conf.yml
CHANGED