dyndnsd 2.0.0.rc2 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +31 -3
- data/README.md +78 -16
- data/exe/dyndnsd +6 -0
- data/lib/dyndnsd.rb +56 -9
- data/lib/dyndnsd/database.rb +6 -1
- data/lib/dyndnsd/generator/bind.rb +10 -5
- data/lib/dyndnsd/helper.rb +30 -2
- data/lib/dyndnsd/responder/dyndns_style.rb +16 -0
- data/lib/dyndnsd/responder/rest_style.rb +16 -0
- data/lib/dyndnsd/textfile_reporter.rb +14 -0
- data/lib/dyndnsd/updater/command_with_bind_zone.rb +16 -8
- data/lib/dyndnsd/updater/zone_transfer_server.rb +158 -0
- data/lib/dyndnsd/version.rb +2 -1
- metadata +63 -58
- data/.gitignore +0 -3
- data/.rubocop.yml +0 -71
- data/.rubocop_todo.yml +0 -7
- data/.travis.yml +0 -7
- data/Gemfile +0 -3
- data/Rakefile +0 -8
- data/bin/dyndnsd +0 -4
- data/dyndnsd.gemspec +0 -36
- data/spec/daemon_spec.rb +0 -240
- data/spec/spec_helper.rb +0 -8
- data/spec/support/dummy_database.rb +0 -27
- data/spec/support/dummy_updater.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c036941ee751a468f225791fae3b73150db3a8a3e011917e27a9ceb742276c6
|
4
|
+
data.tar.gz: 88217f0be901b27cf7cc018a29c3e5dc56165d4badcecb7d792e36b5f7cbf6fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2fda9af8940e3ce39f0b45e27fd6ac39e9e1168b8bb0fcf38f968bbe61786adb4a073b6da360b62b4f14cafe1b5c08ec8e1b3e66d4fb5a2f51ca6238b5ecd61
|
7
|
+
data.tar.gz: 951ee197de794a9600ab3773f49d71d65a597572dab563af770a2374942c1d4f5fcef4d59fb3ec316990938e28ba6e1244c8c50bf8fc37a5047c5f8452fe9d36
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,34 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## 2.
|
3
|
+
## 2.3.0 (July 20, 2020)
|
4
|
+
|
5
|
+
IMPROVEMENTS:
|
6
|
+
|
7
|
+
- Allow enabling debug logging
|
8
|
+
- Add updater that uses [DNS zone transfers via AXFR (RFC5936)](https://tools.ietf.org/html/rfc5936) to allow any secondary nameserver(s) to fetch the zone contents after (optionally) receiving a [DNS NOTIFY (RFC1996)](https://tools.ietf.org/html/rfc1996) request
|
9
|
+
|
10
|
+
## 2.2.0 (March 6, 2020)
|
11
|
+
|
12
|
+
IMPROVEMENTS:
|
13
|
+
|
14
|
+
- Refactor gemspec based on [recommendations](https://piotrmurach.com/articles/writing-a-ruby-gem-specification/) so tests are now excluded from gem and binaries move to `./exe` directory
|
15
|
+
- Adopt Ruby 2.3 frozen string literals for source code potentially reducing memory consumption
|
16
|
+
|
17
|
+
## 2.1.1 (March 1, 2020)
|
18
|
+
|
19
|
+
IMPROVEMENTS:
|
20
|
+
|
21
|
+
- Fix potential `nil` cases detected by [Sorbet](https://sorbet.org) including refactorings
|
22
|
+
|
23
|
+
## 2.1.0 (March 1, 2020)
|
24
|
+
|
25
|
+
IMPROVEMENTS:
|
26
|
+
|
27
|
+
- Add Ruby 2.7 support
|
28
|
+
- Add [solargraph](https://github.com/castwide/solargraph) to dev tooling as Ruby Language Server usable e.g. for IDEs (used solargraph version not compatible with Ruby 2.7 as bundler-audit 0.6.x requires old `thor` gem)
|
29
|
+
- Document code using YARD tags, e.g. for type information and better code completion
|
30
|
+
|
31
|
+
## 2.0.0 (January 25, 2019)
|
4
32
|
|
5
33
|
IMPROVEMENTS:
|
6
34
|
|
@@ -8,8 +36,8 @@ IMPROVEMENTS:
|
|
8
36
|
- Better protocol compliance by returning `badauth` in response body on HTTP 401 errors
|
9
37
|
- Better code maintainability by refactorings
|
10
38
|
- Update dependencies, mainly `rack` to new major version 2
|
11
|
-
- Add Ruby 2.5 support
|
12
|
-
- Add experimental [OpenTracing](
|
39
|
+
- Add Ruby 2.5 and Ruby 2.6 support
|
40
|
+
- Add experimental [OpenTracing](https://opentracing.io/) support with [CNCF Jaeger](https://github.com/jaegertracing/jaeger)
|
13
41
|
- Support host offlining by deleting the associated DNS records
|
14
42
|
- Add textfile reporter to write Graphite-style metrics (also compatible with [Prometheus](https://prometheus.io/)) into a file
|
15
43
|
|
data/README.md
CHANGED
@@ -4,16 +4,20 @@
|
|
4
4
|
|
5
5
|
A small, lightweight and extensible DynDNS server written with Ruby and Rack.
|
6
6
|
|
7
|
+
|
7
8
|
## Description
|
8
9
|
|
9
|
-
dyndnsd.rb aims to implement a small [DynDNS-compliant](https://help.dyn.com/remote-access-api/) server in Ruby supporting IPv4 and IPv6 addresses. It has an integrated user and hostname database in
|
10
|
+
dyndnsd.rb aims to implement a small [DynDNS-compliant](https://help.dyn.com/remote-access-api/) server in Ruby supporting IPv4 and IPv6 addresses. It has an integrated user and hostname database in its configuration file that is used for authentication and authorization. Besides talking the DynDNS protocol it is able to invoke a so-called *updater*, a small Ruby module that takes care of supplying the current hostname => ip mapping to a DNS server.
|
10
11
|
|
11
|
-
There
|
12
|
+
There are currently two updaters shipped with dyndnsd.rb:
|
13
|
+
- `zone_transfer_server` that uses [DNS zone transfers via AXFR (RFC5936)](https://tools.ietf.org/html/rfc5936) to allow any secondary nameserver(s) to fetch the zone contents after (optionally) receiving a [DNS NOTIFY (RFC1996)](https://tools.ietf.org/html/rfc1996) request
|
14
|
+
- `command_with_bind_zone` that writes out a zone file in BIND syntax onto the current system and invokes a user-supplied command afterwards that is assumed to trigger the DNS server (not necessarily BIND since its zone files are read by other DNS servers, too) to reload its zone configuration
|
12
15
|
|
13
16
|
Because of the mechanisms used, dyndnsd.rb is known to work only on \*nix systems.
|
14
17
|
|
15
18
|
See the [changelog](CHANGELOG.md) before upgrading. The older version 1.x of dyndnsd.rb is still available on [branch dyndnsd-1.x](https://github.com/cmur2/dyndnsd/tree/dyndnsd-1.x).
|
16
19
|
|
20
|
+
|
17
21
|
## General Usage
|
18
22
|
|
19
23
|
Install the gem:
|
@@ -25,14 +29,16 @@ Create a configuration file in YAML format somewhere:
|
|
25
29
|
```yaml
|
26
30
|
# listen address and port
|
27
31
|
host: "0.0.0.0"
|
28
|
-
port:
|
29
|
-
# optional: drop
|
32
|
+
port: 80
|
33
|
+
# optional: drop privileges in case you want to but you may need sudo for external commands
|
30
34
|
user: "nobody"
|
31
35
|
group: "nogroup"
|
32
|
-
# logfile is optional, logs to STDOUT
|
36
|
+
# logfile is optional, logs to STDOUT otherwise
|
33
37
|
logfile: "dyndnsd.log"
|
34
|
-
#
|
38
|
+
# internal database file
|
35
39
|
db: "db.json"
|
40
|
+
# enable debug mode?
|
41
|
+
debug: false
|
36
42
|
# all hostnames are required to be cool-name.example.org
|
37
43
|
domain: "example.org"
|
38
44
|
# configure the updater, here we use command_with_bind_zone, params are updater-specific
|
@@ -60,15 +66,61 @@ Run dyndnsd.rb by:
|
|
60
66
|
|
61
67
|
dyndnsd /path/to/config.yaml
|
62
68
|
|
63
|
-
## Using dyndnsd.rb with [NSD](https://www.nlnetlabs.nl/nsd/)
|
64
69
|
|
65
|
-
|
70
|
+
## Using dyndnsd.rb with any nameserver via DNS zone transfers (AXFR)
|
71
|
+
|
72
|
+
By using [DNS zone transfers via AXFR (RFC5936)](https://tools.ietf.org/html/rfc5936) any secondary nameserver can retrieve the DNS zone contents from dyndnsd.rb and serve them to clients.
|
73
|
+
To speedup propagation after changes dyndnsd.rb can issue a [DNS NOTIFY (RFC1996)](https://tools.ietf.org/html/rfc1996) to inform the nameserver that the DNS zone contents changed and should be fetched even before the time indicated in the SOA record is up.
|
74
|
+
Currently dyndnsd.rb does not support any authentication for incoming DNS zone transfer requests so it should be isolated from the internet on these ports.
|
75
|
+
|
76
|
+
This approach has several advantages:
|
77
|
+
- dyndnsd.rb can be used in *hidden primary* fashion isolated from client's DNS traffic and does not need to implement full nameserver features
|
78
|
+
- any existing, production-grade, caching, geo-replicated nameserver setup can be used to pull DNS zone contents from the *hidden primary* dyndnsd.rb and serve it to clients
|
79
|
+
- any nameserver(s) and dyndnsd.rb do not need to be located on the same host
|
80
|
+
|
81
|
+
Example dyndnsd.rb configuration:
|
82
|
+
|
83
|
+
```yaml
|
84
|
+
host: "0.0.0.0"
|
85
|
+
port: 8245 # the DynDNS.com alternative HTTP port
|
86
|
+
db: "/opt/dyndnsd/db.json"
|
87
|
+
domain: "dyn.example.org"
|
88
|
+
updater:
|
89
|
+
name: "zone_transfer_server"
|
90
|
+
params:
|
91
|
+
# endpoint(s) to listen for incoming zone transfer (AXFR) requests, default 0.0.0.0@53
|
92
|
+
server_listens:
|
93
|
+
- 127.0.0.1@5300
|
94
|
+
# where to send DNS NOTIFY request(s) to on zone content change
|
95
|
+
send_notifies:
|
96
|
+
- '127.0.0.1'
|
97
|
+
# TTL for all records in the zone (in seconds)
|
98
|
+
zone_ttl: 300 # 5m
|
99
|
+
# zone's NS record(s) (at least one)
|
100
|
+
zone_nameservers:
|
101
|
+
- "dns.example.org."
|
102
|
+
# info for zone's SOA record
|
103
|
+
zone_email_address: "admin.example.org."
|
104
|
+
# zone's additional A/AAAA records
|
105
|
+
zone_additional_ips:
|
106
|
+
- "127.0.0.1"
|
107
|
+
users:
|
108
|
+
foo:
|
109
|
+
password: "secret"
|
110
|
+
hosts:
|
111
|
+
- foo.example.org
|
112
|
+
```
|
113
|
+
|
114
|
+
|
115
|
+
## Using dyndnsd.rb with [NSD](https://www.nlnetlabs.nl/projects/nsd/about/)
|
66
116
|
|
67
|
-
|
117
|
+
NSD is a nice, open source, authoritative-only, low-memory DNS server that reads BIND-style zone files (and converts them into its own database) and has a simple configuration file.
|
118
|
+
|
119
|
+
A feature NSD is lacking is the [Dynamic DNS update (RFC2136)](https://tools.ietf.org/html/rfc2136) functionality BIND offers but one can fake it using the following dyndnsd.rb configuration:
|
68
120
|
|
69
121
|
```yaml
|
70
122
|
host: "0.0.0.0"
|
71
|
-
port:
|
123
|
+
port: 8245 # the DynDNS.com alternative HTTP port
|
72
124
|
db: "/opt/dyndnsd/db.json"
|
73
125
|
domain: "dyn.example.org"
|
74
126
|
updater:
|
@@ -88,17 +140,20 @@ users:
|
|
88
140
|
foo:
|
89
141
|
password: "secret"
|
90
142
|
hosts:
|
91
|
-
- foo.example.org
|
143
|
+
- foo.example.org
|
92
144
|
```
|
93
145
|
|
94
146
|
Start dyndnsd.rb before NSD to make sure the zone file exists else NSD complains.
|
95
147
|
|
148
|
+
|
96
149
|
## Using dyndnsd.rb with X
|
97
150
|
|
98
151
|
Please provide ideas if you are using dyndnsd.rb with other DNS servers :)
|
99
152
|
|
153
|
+
|
100
154
|
## Advanced topics
|
101
155
|
|
156
|
+
|
102
157
|
### Update URL
|
103
158
|
|
104
159
|
The update URL you want to tell your clients (humans or scripts ^^) consists of the following
|
@@ -111,10 +166,11 @@ where:
|
|
111
166
|
* USER and PASSWORD are needed for HTTP Basic Auth and valid combinations are defined in your config.yaml
|
112
167
|
* DOMAIN should match what you defined in your config.yaml as domain but may be anything else when using a webserver as proxy
|
113
168
|
* PORT depends on your (webserver/proxy) settings
|
114
|
-
* HOSTNAMES is a required list of comma
|
169
|
+
* HOSTNAMES is a required list of comma-separated FQDNs (they all have to end with your config.yaml domain) the user wants to update
|
115
170
|
* MYIP is optional and the HTTP client's IP address will be used if missing
|
116
171
|
* MYIP6 is optional but if present also requires presence of MYIP
|
117
172
|
|
173
|
+
|
118
174
|
### IP address determination
|
119
175
|
|
120
176
|
The following rules apply:
|
@@ -123,23 +179,26 @@ The following rules apply:
|
|
123
179
|
* use any IP address provided via the X-Real-IP header e.g. when used behind HTTP reverse proxy such as nginx, or
|
124
180
|
* use any IP address used by the connecting HTTP client
|
125
181
|
|
126
|
-
If you want to provide an additional IPv6 address as myip6 parameter the myip parameter containing an IPv4 address has to be present, too! No automatism is applied then.
|
182
|
+
If you want to provide an additional IPv6 address as myip6 parameter, the myip parameter containing an IPv4 address has to be present, too! No automatism is applied then.
|
183
|
+
|
127
184
|
|
128
185
|
### SSL, multiple listen ports
|
129
186
|
|
130
187
|
Use a webserver as a proxy to handle SSL and/or multiple listen addresses and ports. DynDNS.com provides HTTP on port 80 and 8245 and HTTPS on port 443.
|
131
188
|
|
189
|
+
|
132
190
|
### Init scripts
|
133
191
|
|
134
192
|
The [Debian 6 init.d script](init.d/debian-6-dyndnsd) assumes that dyndnsd.rb is installed into the system ruby (no RVM support) and the config.yaml is at /opt/dyndnsd/config.yaml. Modify to your needs.
|
135
193
|
|
194
|
+
|
136
195
|
### Monitoring
|
137
196
|
|
138
197
|
For monitoring dyndnsd.rb uses the [metriks](https://github.com/eric/metriks) framework and exposes several metrics like the number of unauthenticated requests, requests that did (not) update a hostname, etc. By default the most important metrics are shown in the [proctitle](https://github.com/eric/metriks#proc-title-reporter) but you can also configure a [Graphite](https://graphiteapp.org/) backend for central monitoring or the [textfile_reporter](https://github.com/prometheus/node_exporter/#textfile-collector) which outputs Graphite-style metrics that are also compatible with Prometheus to a file.
|
139
198
|
|
140
199
|
```yaml
|
141
200
|
host: "0.0.0.0"
|
142
|
-
port:
|
201
|
+
port: 8245 # the DynDNS.com alternative HTTP port
|
143
202
|
db: "/opt/dyndnsd/db.json"
|
144
203
|
domain: "dyn.example.org"
|
145
204
|
# configure the Graphite backend to be used instead of proctitle
|
@@ -172,14 +231,16 @@ users:
|
|
172
231
|
password: "ihavenohosts"
|
173
232
|
```
|
174
233
|
|
234
|
+
|
175
235
|
### Tracing (experimental)
|
176
236
|
|
177
|
-
For tracing dyndnsd.rb is instrumented using the [OpenTracing](http://opentracing.io/) framework and will emit span tracing data for the most important operations happening during the request/response cycle. Using a middleware for Rack allows handling incoming OpenTracing span information properly.
|
237
|
+
For tracing, dyndnsd.rb is instrumented using the [OpenTracing](http://opentracing.io/) framework and will emit span tracing data for the most important operations happening during the request/response cycle. Using a middleware for Rack allows handling incoming OpenTracing span information properly.
|
238
|
+
|
178
239
|
Currently only one OpenTracing-compatible tracer implementation named [CNCF Jaeger](https://github.com/jaegertracing/jaeger) can be configured to use with dyndnsd.rb.
|
179
240
|
|
180
241
|
```yaml
|
181
242
|
host: "0.0.0.0"
|
182
|
-
port:
|
243
|
+
port: 8245 # the DynDNS.com alternative HTTP port
|
183
244
|
db: "/opt/dyndnsd/db.json"
|
184
245
|
domain: "dyn.example.org"
|
185
246
|
# enable and configure tracing using the (currently only) tracer jaeger
|
@@ -210,6 +271,7 @@ users:
|
|
210
271
|
password: "ihavenohosts"
|
211
272
|
```
|
212
273
|
|
274
|
+
|
213
275
|
## License
|
214
276
|
|
215
277
|
dyndnsd.rb is licensed under the Apache License, Version 2.0. See LICENSE for more information.
|
data/exe/dyndnsd
ADDED
data/lib/dyndnsd.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'etc'
|
4
4
|
require 'logger'
|
@@ -10,10 +10,10 @@ require 'metriks'
|
|
10
10
|
require 'metriks/reporter/graphite'
|
11
11
|
require 'opentracing'
|
12
12
|
require 'rack/tracer'
|
13
|
-
require 'spanmanager'
|
14
13
|
|
15
14
|
require 'dyndnsd/generator/bind'
|
16
15
|
require 'dyndnsd/updater/command_with_bind_zone'
|
16
|
+
require 'dyndnsd/updater/zone_transfer_server'
|
17
17
|
require 'dyndnsd/responder/dyndns_style'
|
18
18
|
require 'dyndnsd/responder/rest_style'
|
19
19
|
require 'dyndnsd/database'
|
@@ -22,21 +22,32 @@ require 'dyndnsd/textfile_reporter'
|
|
22
22
|
require 'dyndnsd/version'
|
23
23
|
|
24
24
|
module Dyndnsd
|
25
|
+
# @return [Logger]
|
25
26
|
def self.logger
|
26
27
|
@logger
|
27
28
|
end
|
28
29
|
|
30
|
+
# @param logger [Logger]
|
31
|
+
# @return [Logger]
|
29
32
|
def self.logger=(logger)
|
30
33
|
@logger = logger
|
31
34
|
end
|
32
35
|
|
33
36
|
class LogFormatter
|
37
|
+
# @param lvl [Object]
|
38
|
+
# @param _time [DateTime]
|
39
|
+
# @param _progname [String]
|
40
|
+
# @param msg [Object]
|
41
|
+
# @return [String]
|
34
42
|
def call(lvl, _time, _progname, msg)
|
35
43
|
format("[%s] %-5s %s\n", Time.now.strftime('%Y-%m-%d %H:%M:%S'), lvl, msg.to_s)
|
36
44
|
end
|
37
45
|
end
|
38
46
|
|
39
47
|
class Daemon
|
48
|
+
# @param config [Hash{String => Object}]
|
49
|
+
# @param db [Dyndnsd::Database]
|
50
|
+
# @param updater [#update]
|
40
51
|
def initialize(config, db, updater)
|
41
52
|
@users = config['users']
|
42
53
|
@domain = config['domain']
|
@@ -46,12 +57,15 @@ module Dyndnsd
|
|
46
57
|
@db.load
|
47
58
|
@db['serial'] ||= 1
|
48
59
|
@db['hosts'] ||= {}
|
60
|
+
@updater.update(@db)
|
49
61
|
if @db.changed?
|
50
62
|
@db.save
|
51
|
-
@updater.update(@db)
|
52
63
|
end
|
53
64
|
end
|
54
65
|
|
66
|
+
# @param username [String]
|
67
|
+
# @param password [String]
|
68
|
+
# @return [Boolean]
|
55
69
|
def authorized?(username, password)
|
56
70
|
Helper.span('check_authorized') do |span|
|
57
71
|
span.set_tag('dyndnsd.user', username)
|
@@ -65,6 +79,8 @@ module Dyndnsd
|
|
65
79
|
end
|
66
80
|
end
|
67
81
|
|
82
|
+
# @param env [Hash{String => String}]
|
83
|
+
# @return [Array{Integer,Hash{String => String},Array{String}}]
|
68
84
|
def call(env)
|
69
85
|
return [422, {'X-DynDNS-Response' => 'method_forbidden'}, []] if env['REQUEST_METHOD'] != 'GET'
|
70
86
|
return [422, {'X-DynDNS-Response' => 'not_found'}, []] if env['PATH_INFO'] != '/nic/update'
|
@@ -72,6 +88,7 @@ module Dyndnsd
|
|
72
88
|
handle_dyndns_request(env)
|
73
89
|
end
|
74
90
|
|
91
|
+
# @return [void]
|
75
92
|
def self.run!
|
76
93
|
if ARGV.length != 1
|
77
94
|
puts 'Usage: dyndnsd config_file'
|
@@ -96,8 +113,14 @@ module Dyndnsd
|
|
96
113
|
|
97
114
|
# drop priviliges as soon as possible
|
98
115
|
# NOTE: first change group than user
|
99
|
-
|
100
|
-
|
116
|
+
if config['group']
|
117
|
+
group = Etc.getgrnam(config['group'])
|
118
|
+
Process::Sys.setgid(group.gid) if group
|
119
|
+
end
|
120
|
+
if config['user']
|
121
|
+
user = Etc.getpwnam(config['user'])
|
122
|
+
Process::Sys.setuid(user.uid) if user
|
123
|
+
end
|
101
124
|
|
102
125
|
setup_traps
|
103
126
|
|
@@ -110,6 +133,8 @@ module Dyndnsd
|
|
110
133
|
|
111
134
|
private
|
112
135
|
|
136
|
+
# @param params [Hash{String => String}]
|
137
|
+
# @return [Array{String}]
|
113
138
|
def extract_v4_and_v6_address(params)
|
114
139
|
return [] if !(params['myip'])
|
115
140
|
begin
|
@@ -121,6 +146,9 @@ module Dyndnsd
|
|
121
146
|
end
|
122
147
|
end
|
123
148
|
|
149
|
+
# @param env [Hash{String => String}]
|
150
|
+
# @param params [Hash{String => String}]
|
151
|
+
# @return [Array{String}]
|
124
152
|
def extract_myips(env, params)
|
125
153
|
# require presence of myip parameter as valid IPAddr (v4) and valid myip6
|
126
154
|
return extract_v4_and_v6_address(params) if params.key?('myip6')
|
@@ -135,6 +163,9 @@ module Dyndnsd
|
|
135
163
|
[env['REMOTE_ADDR']]
|
136
164
|
end
|
137
165
|
|
166
|
+
# @param hostnames [String]
|
167
|
+
# @param myips [Array{String}]
|
168
|
+
# @return [Array{Symbol}]
|
138
169
|
def process_changes(hostnames, myips)
|
139
170
|
changes = []
|
140
171
|
Helper.span('process_changes') do |span|
|
@@ -159,14 +190,17 @@ module Dyndnsd
|
|
159
190
|
changes
|
160
191
|
end
|
161
192
|
|
193
|
+
# @return [void]
|
162
194
|
def update_db
|
163
195
|
@db['serial'] += 1
|
164
196
|
Dyndnsd.logger.info "Committing update ##{@db['serial']}"
|
165
|
-
@db.save
|
166
197
|
@updater.update(@db)
|
198
|
+
@db.save
|
167
199
|
Metriks.meter('updates.committed').mark
|
168
200
|
end
|
169
201
|
|
202
|
+
# @param env [Hash{String => String}]
|
203
|
+
# @return [Array{Integer,Hash{String => String},Array{String}}]
|
170
204
|
def handle_dyndns_request(env)
|
171
205
|
params = Rack::Utils.parse_query(env['QUERY_STRING'])
|
172
206
|
|
@@ -205,6 +239,8 @@ module Dyndnsd
|
|
205
239
|
|
206
240
|
# SETUP
|
207
241
|
|
242
|
+
# @param config [Hash{String => Object}]
|
243
|
+
# @return [void]
|
208
244
|
private_class_method def self.setup_logger(config)
|
209
245
|
if config['logfile']
|
210
246
|
Dyndnsd.logger = Logger.new(config['logfile'])
|
@@ -214,8 +250,10 @@ module Dyndnsd
|
|
214
250
|
|
215
251
|
Dyndnsd.logger.progname = 'dyndnsd'
|
216
252
|
Dyndnsd.logger.formatter = LogFormatter.new
|
253
|
+
Dyndnsd.logger.level = config['debug'] ? Logger::DEBUG : Logger::INFO
|
217
254
|
end
|
218
255
|
|
256
|
+
# @return [void]
|
219
257
|
private_class_method def self.setup_traps
|
220
258
|
Signal.trap('INT') do
|
221
259
|
Dyndnsd.logger.info 'Quitting...'
|
@@ -227,6 +265,8 @@ module Dyndnsd
|
|
227
265
|
end
|
228
266
|
end
|
229
267
|
|
268
|
+
# @param config [Hash{String => Object}]
|
269
|
+
# @return [void]
|
230
270
|
private_class_method def self.setup_monitoring(config)
|
231
271
|
# configure metriks
|
232
272
|
if config['graphite']
|
@@ -254,6 +294,8 @@ module Dyndnsd
|
|
254
294
|
end
|
255
295
|
end
|
256
296
|
|
297
|
+
# @param config [Hash{String => Object}]
|
298
|
+
# @return [void]
|
257
299
|
private_class_method def self.setup_tracing(config)
|
258
300
|
# configure OpenTracing
|
259
301
|
if config.dig('tracing', 'jaeger')
|
@@ -266,14 +308,19 @@ module Dyndnsd
|
|
266
308
|
host: host, port: port, service_name: service_name, flush_interval: 1
|
267
309
|
)
|
268
310
|
end
|
269
|
-
# always use SpanManager
|
270
|
-
OpenTracing.global_tracer = SpanManager::Tracer.new(OpenTracing.global_tracer)
|
271
311
|
end
|
272
312
|
|
313
|
+
# @param config [Hash{String => Object}]
|
314
|
+
# @return [void]
|
273
315
|
private_class_method def self.setup_rack(config)
|
274
316
|
# configure daemon
|
275
317
|
db = Database.new(config['db'])
|
276
|
-
|
318
|
+
case config.dig('updater', 'name')
|
319
|
+
when 'command_with_bind_zone'
|
320
|
+
updater = Updater::CommandWithBindZone.new(config['domain'], config.dig('updater', 'params'))
|
321
|
+
when 'zone_transfer_server'
|
322
|
+
updater = Updater::ZoneTransferServer.new(config['domain'], config.dig('updater', 'params'))
|
323
|
+
end
|
277
324
|
daemon = Daemon.new(config, db, updater)
|
278
325
|
|
279
326
|
# configure rack
|