dyndnsd 2.0.0 → 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +35 -1
- data/README.md +78 -16
- data/exe/dyndnsd +6 -0
- data/lib/dyndnsd.rb +56 -8
- data/lib/dyndnsd/database.rb +6 -1
- data/lib/dyndnsd/generator/bind.rb +10 -5
- data/lib/dyndnsd/helper.rb +18 -1
- 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 +50 -45
- data/.gitignore +0 -3
- data/.rubocop.yml +0 -80
- data/.rubocop_todo.yml +0 -7
- data/.travis.yml +0 -8
- data/Gemfile +0 -3
- data/Rakefile +0 -10
- 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: 3bfdbe62ef8dcbfc69c8a62e0dd06a2ee5bcdddaf1acc3bbbc5ed238e5286e5f
|
4
|
+
data.tar.gz: a61794c2d98d0aba28fc37ce5ebe7928f4455a2fda5ce945591715db3c85df97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbeeb01c67a5aeb4098b19d7eb91abaf532b24fc007dec60eff1a3dcba771aa9a1d648fa7041319f770eabc3461ea211c6818dd8c1fb15c9d5b201f5df9c014c
|
7
|
+
data.tar.gz: 907c75c30d95843b0fa32544db157b67dba8921ba167e909e5aeb96133e9abe887a3a4709fa300b4437563bd2f0d558a03ebb18978f030beab043361d421dd6f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,39 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 2.3.1 (July 27, 2020)
|
4
|
+
|
5
|
+
IMPROVEMENTS:
|
6
|
+
|
7
|
+
- Fix annoying error message `log writing failed. can't be called from trap context` on shutdown by not attempting to log redundant information there
|
8
|
+
|
9
|
+
## 2.3.0 (July 20, 2020)
|
10
|
+
|
11
|
+
IMPROVEMENTS:
|
12
|
+
|
13
|
+
- Allow enabling debug logging
|
14
|
+
- 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
|
15
|
+
|
16
|
+
## 2.2.0 (March 6, 2020)
|
17
|
+
|
18
|
+
IMPROVEMENTS:
|
19
|
+
|
20
|
+
- 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
|
21
|
+
- Adopt Ruby 2.3 frozen string literals for source code potentially reducing memory consumption
|
22
|
+
|
23
|
+
## 2.1.1 (March 1, 2020)
|
24
|
+
|
25
|
+
IMPROVEMENTS:
|
26
|
+
|
27
|
+
- Fix potential `nil` cases detected by [Sorbet](https://sorbet.org) including refactorings
|
28
|
+
|
29
|
+
## 2.1.0 (March 1, 2020)
|
30
|
+
|
31
|
+
IMPROVEMENTS:
|
32
|
+
|
33
|
+
- Add Ruby 2.7 support
|
34
|
+
- 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)
|
35
|
+
- Document code using YARD tags, e.g. for type information and better code completion
|
36
|
+
|
3
37
|
## 2.0.0 (January 25, 2019)
|
4
38
|
|
5
39
|
IMPROVEMENTS:
|
@@ -9,7 +43,7 @@ IMPROVEMENTS:
|
|
9
43
|
- Better code maintainability by refactorings
|
10
44
|
- Update dependencies, mainly `rack` to new major version 2
|
11
45
|
- Add Ruby 2.5 and Ruby 2.6 support
|
12
|
-
- Add experimental [OpenTracing](
|
46
|
+
- Add experimental [OpenTracing](https://opentracing.io/) support with [CNCF Jaeger](https://github.com/jaegertracing/jaeger)
|
13
47
|
- Support host offlining by deleting the associated DNS records
|
14
48
|
- Add textfile reporter to write Graphite-style metrics (also compatible with [Prometheus](https://prometheus.io/)) into a file
|
15
49
|
|
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'
|
@@ -13,6 +13,7 @@ require 'rack/tracer'
|
|
13
13
|
|
14
14
|
require 'dyndnsd/generator/bind'
|
15
15
|
require 'dyndnsd/updater/command_with_bind_zone'
|
16
|
+
require 'dyndnsd/updater/zone_transfer_server'
|
16
17
|
require 'dyndnsd/responder/dyndns_style'
|
17
18
|
require 'dyndnsd/responder/rest_style'
|
18
19
|
require 'dyndnsd/database'
|
@@ -21,21 +22,32 @@ require 'dyndnsd/textfile_reporter'
|
|
21
22
|
require 'dyndnsd/version'
|
22
23
|
|
23
24
|
module Dyndnsd
|
25
|
+
# @return [Logger]
|
24
26
|
def self.logger
|
25
27
|
@logger
|
26
28
|
end
|
27
29
|
|
30
|
+
# @param logger [Logger]
|
31
|
+
# @return [Logger]
|
28
32
|
def self.logger=(logger)
|
29
33
|
@logger = logger
|
30
34
|
end
|
31
35
|
|
32
36
|
class LogFormatter
|
37
|
+
# @param lvl [Object]
|
38
|
+
# @param _time [DateTime]
|
39
|
+
# @param _progname [String]
|
40
|
+
# @param msg [Object]
|
41
|
+
# @return [String]
|
33
42
|
def call(lvl, _time, _progname, msg)
|
34
43
|
format("[%s] %-5s %s\n", Time.now.strftime('%Y-%m-%d %H:%M:%S'), lvl, msg.to_s)
|
35
44
|
end
|
36
45
|
end
|
37
46
|
|
38
47
|
class Daemon
|
48
|
+
# @param config [Hash{String => Object}]
|
49
|
+
# @param db [Dyndnsd::Database]
|
50
|
+
# @param updater [#update]
|
39
51
|
def initialize(config, db, updater)
|
40
52
|
@users = config['users']
|
41
53
|
@domain = config['domain']
|
@@ -45,12 +57,15 @@ module Dyndnsd
|
|
45
57
|
@db.load
|
46
58
|
@db['serial'] ||= 1
|
47
59
|
@db['hosts'] ||= {}
|
60
|
+
@updater.update(@db)
|
48
61
|
if @db.changed?
|
49
62
|
@db.save
|
50
|
-
@updater.update(@db)
|
51
63
|
end
|
52
64
|
end
|
53
65
|
|
66
|
+
# @param username [String]
|
67
|
+
# @param password [String]
|
68
|
+
# @return [Boolean]
|
54
69
|
def authorized?(username, password)
|
55
70
|
Helper.span('check_authorized') do |span|
|
56
71
|
span.set_tag('dyndnsd.user', username)
|
@@ -64,6 +79,8 @@ module Dyndnsd
|
|
64
79
|
end
|
65
80
|
end
|
66
81
|
|
82
|
+
# @param env [Hash{String => String}]
|
83
|
+
# @return [Array{Integer,Hash{String => String},Array{String}}]
|
67
84
|
def call(env)
|
68
85
|
return [422, {'X-DynDNS-Response' => 'method_forbidden'}, []] if env['REQUEST_METHOD'] != 'GET'
|
69
86
|
return [422, {'X-DynDNS-Response' => 'not_found'}, []] if env['PATH_INFO'] != '/nic/update'
|
@@ -71,6 +88,7 @@ module Dyndnsd
|
|
71
88
|
handle_dyndns_request(env)
|
72
89
|
end
|
73
90
|
|
91
|
+
# @return [void]
|
74
92
|
def self.run!
|
75
93
|
if ARGV.length != 1
|
76
94
|
puts 'Usage: dyndnsd config_file'
|
@@ -95,8 +113,14 @@ module Dyndnsd
|
|
95
113
|
|
96
114
|
# drop priviliges as soon as possible
|
97
115
|
# NOTE: first change group than user
|
98
|
-
|
99
|
-
|
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
|
100
124
|
|
101
125
|
setup_traps
|
102
126
|
|
@@ -109,6 +133,8 @@ module Dyndnsd
|
|
109
133
|
|
110
134
|
private
|
111
135
|
|
136
|
+
# @param params [Hash{String => String}]
|
137
|
+
# @return [Array{String}]
|
112
138
|
def extract_v4_and_v6_address(params)
|
113
139
|
return [] if !(params['myip'])
|
114
140
|
begin
|
@@ -120,6 +146,9 @@ module Dyndnsd
|
|
120
146
|
end
|
121
147
|
end
|
122
148
|
|
149
|
+
# @param env [Hash{String => String}]
|
150
|
+
# @param params [Hash{String => String}]
|
151
|
+
# @return [Array{String}]
|
123
152
|
def extract_myips(env, params)
|
124
153
|
# require presence of myip parameter as valid IPAddr (v4) and valid myip6
|
125
154
|
return extract_v4_and_v6_address(params) if params.key?('myip6')
|
@@ -134,6 +163,9 @@ module Dyndnsd
|
|
134
163
|
[env['REMOTE_ADDR']]
|
135
164
|
end
|
136
165
|
|
166
|
+
# @param hostnames [String]
|
167
|
+
# @param myips [Array{String}]
|
168
|
+
# @return [Array{Symbol}]
|
137
169
|
def process_changes(hostnames, myips)
|
138
170
|
changes = []
|
139
171
|
Helper.span('process_changes') do |span|
|
@@ -158,14 +190,17 @@ module Dyndnsd
|
|
158
190
|
changes
|
159
191
|
end
|
160
192
|
|
193
|
+
# @return [void]
|
161
194
|
def update_db
|
162
195
|
@db['serial'] += 1
|
163
196
|
Dyndnsd.logger.info "Committing update ##{@db['serial']}"
|
164
|
-
@db.save
|
165
197
|
@updater.update(@db)
|
198
|
+
@db.save
|
166
199
|
Metriks.meter('updates.committed').mark
|
167
200
|
end
|
168
201
|
|
202
|
+
# @param env [Hash{String => String}]
|
203
|
+
# @return [Array{Integer,Hash{String => String},Array{String}}]
|
169
204
|
def handle_dyndns_request(env)
|
170
205
|
params = Rack::Utils.parse_query(env['QUERY_STRING'])
|
171
206
|
|
@@ -204,6 +239,8 @@ module Dyndnsd
|
|
204
239
|
|
205
240
|
# SETUP
|
206
241
|
|
242
|
+
# @param config [Hash{String => Object}]
|
243
|
+
# @return [void]
|
207
244
|
private_class_method def self.setup_logger(config)
|
208
245
|
if config['logfile']
|
209
246
|
Dyndnsd.logger = Logger.new(config['logfile'])
|
@@ -213,19 +250,21 @@ module Dyndnsd
|
|
213
250
|
|
214
251
|
Dyndnsd.logger.progname = 'dyndnsd'
|
215
252
|
Dyndnsd.logger.formatter = LogFormatter.new
|
253
|
+
Dyndnsd.logger.level = config['debug'] ? Logger::DEBUG : Logger::INFO
|
216
254
|
end
|
217
255
|
|
256
|
+
# @return [void]
|
218
257
|
private_class_method def self.setup_traps
|
219
258
|
Signal.trap('INT') do
|
220
|
-
Dyndnsd.logger.info 'Quitting...'
|
221
259
|
Rack::Handler::WEBrick.shutdown
|
222
260
|
end
|
223
261
|
Signal.trap('TERM') do
|
224
|
-
Dyndnsd.logger.info 'Quitting...'
|
225
262
|
Rack::Handler::WEBrick.shutdown
|
226
263
|
end
|
227
264
|
end
|
228
265
|
|
266
|
+
# @param config [Hash{String => Object}]
|
267
|
+
# @return [void]
|
229
268
|
private_class_method def self.setup_monitoring(config)
|
230
269
|
# configure metriks
|
231
270
|
if config['graphite']
|
@@ -253,6 +292,8 @@ module Dyndnsd
|
|
253
292
|
end
|
254
293
|
end
|
255
294
|
|
295
|
+
# @param config [Hash{String => Object}]
|
296
|
+
# @return [void]
|
256
297
|
private_class_method def self.setup_tracing(config)
|
257
298
|
# configure OpenTracing
|
258
299
|
if config.dig('tracing', 'jaeger')
|
@@ -267,10 +308,17 @@ module Dyndnsd
|
|
267
308
|
end
|
268
309
|
end
|
269
310
|
|
311
|
+
# @param config [Hash{String => Object}]
|
312
|
+
# @return [void]
|
270
313
|
private_class_method def self.setup_rack(config)
|
271
314
|
# configure daemon
|
272
315
|
db = Database.new(config['db'])
|
273
|
-
|
316
|
+
case config.dig('updater', 'name')
|
317
|
+
when 'command_with_bind_zone'
|
318
|
+
updater = Updater::CommandWithBindZone.new(config['domain'], config.dig('updater', 'params'))
|
319
|
+
when 'zone_transfer_server'
|
320
|
+
updater = Updater::ZoneTransferServer.new(config['domain'], config.dig('updater', 'params'))
|
321
|
+
end
|
274
322
|
daemon = Daemon.new(config, db, updater)
|
275
323
|
|
276
324
|
# configure rack
|