dyndnsd 2.1.1 → 3.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +32 -0
- data/README.md +118 -19
- data/exe/dyndnsd +6 -0
- data/lib/dyndnsd.rb +19 -13
- data/lib/dyndnsd/database.rb +1 -0
- data/lib/dyndnsd/generator/bind.rb +8 -7
- data/lib/dyndnsd/helper.rb +1 -0
- data/lib/dyndnsd/responder/dyndns_style.rb +14 -11
- data/lib/dyndnsd/responder/rest_style.rb +14 -11
- data/lib/dyndnsd/textfile_reporter.rb +6 -7
- data/lib/dyndnsd/updater/command_with_bind_zone.rb +9 -5
- data/lib/dyndnsd/updater/zone_transfer_server.rb +158 -0
- data/lib/dyndnsd/version.rb +2 -1
- metadata +48 -57
- data/.gitignore +0 -4
- data/.rubocop.yml +0 -87
- data/.solargraph.yml +0 -16
- data/.travis.yml +0 -12
- data/Gemfile +0 -3
- data/Rakefile +0 -22
- data/bin/dyndnsd +0 -4
- data/dyndnsd.gemspec +0 -37
- data/init.d/debian-6-dyndnsd +0 -43
- 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: 9b6bde5e231b0cfaa5f574a8d273a234fe80220e3c1d921f95d4b545f5b79e27
|
4
|
+
data.tar.gz: 44c577daf4ad17e698304b49dda8ca4ba2b9f6009fee4e652c44531a0fff10e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0eeacccc297ff9d083ad76c0ecab842e2989f869c0cab83bb902ffe1371787e12919f57aa170dda3af7189f8e037800338b96b3ab17eef042c9df2061956c239
|
7
|
+
data.tar.gz: 8b2fc766f3017e0045dc9e73a94f00281743f3f870a43eff97080dbc3b1e2477bcbf5c2eb3a6be14be87d311da744aa46e2d6fd89579b167503c95e2990def17
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,37 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 3.1.0
|
4
|
+
|
5
|
+
IMPROVEMENTS:
|
6
|
+
|
7
|
+
- Add officially maintained [Docker image for dyndnsd](https://hub.docker.com/r/cmur2/dyndnsd)
|
8
|
+
|
9
|
+
## 3.0.0 (July 29, 2020)
|
10
|
+
|
11
|
+
IMPROVEMENTS:
|
12
|
+
|
13
|
+
- Drop EOL Ruby 2.4 and lower support, now minimum version supported is Ruby 2.5
|
14
|
+
|
15
|
+
## 2.3.1 (July 27, 2020)
|
16
|
+
|
17
|
+
IMPROVEMENTS:
|
18
|
+
|
19
|
+
- Fix annoying error message `log writing failed. can't be called from trap context` on shutdown by not attempting to log redundant information there
|
20
|
+
|
21
|
+
## 2.3.0 (July 20, 2020)
|
22
|
+
|
23
|
+
IMPROVEMENTS:
|
24
|
+
|
25
|
+
- Allow enabling debug logging
|
26
|
+
- 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
|
27
|
+
|
28
|
+
## 2.2.0 (March 6, 2020)
|
29
|
+
|
30
|
+
IMPROVEMENTS:
|
31
|
+
|
32
|
+
- 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
|
33
|
+
- Adopt Ruby 2.3 frozen string literals for source code potentially reducing memory consumption
|
34
|
+
|
3
35
|
## 2.1.1 (March 1, 2020)
|
4
36
|
|
5
37
|
IMPROVEMENTS:
|
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
|
@@ -58,17 +64,98 @@ users:
|
|
58
64
|
|
59
65
|
Run dyndnsd.rb by:
|
60
66
|
|
61
|
-
|
67
|
+
```bash
|
68
|
+
dyndnsd /path/to/config.yml
|
69
|
+
```
|
70
|
+
|
71
|
+
|
72
|
+
### Docker image
|
73
|
+
|
74
|
+
There is an officially maintained [Docker image for dyndnsd](https://hub.docker.com/r/cmur2/dyndnsd) available at Dockerhub. The goal is to have a minimal secured image available (currently based on Alpine) that works well for the `zone_transfer_server` updater use case.
|
75
|
+
|
76
|
+
Users can make extensions by deriving from the official Docker image or building their own.
|
77
|
+
|
78
|
+
The Docker image consumes the same configuration file in YAML format as the gem, inside the container it needs to be mounted/available as `/etc/dyndnsd/config.yml`. the following YAML should be used as a base and extended with user's settings:
|
79
|
+
|
80
|
+
```yaml
|
81
|
+
host: "0.0.0.0"
|
82
|
+
port: 8080
|
83
|
+
# omit the logfile: option so logging to STDOUT will happen automatically
|
84
|
+
db: "/var/lib/db.json"
|
85
|
+
|
86
|
+
# User's settings for updater and permissions follow here!
|
87
|
+
```
|
88
|
+
|
89
|
+
more ports might be needed depending on if DNS zone transfer is needed
|
90
|
+
|
91
|
+
Run the Docker image exposing the DynDNS-API on host port 8080 via:
|
92
|
+
|
93
|
+
```bash
|
94
|
+
docker run -d --name dyndnsd \
|
95
|
+
-p 8080:8080 \
|
96
|
+
-v /host/path/to/dyndnsd/config.yml:/etc/dyndnsd/config.yml \
|
97
|
+
-v /host/path/to/dyndnsd/db.json:/var/lib/db.json \
|
98
|
+
cmur2/dyndnsd:vX.Y.Z
|
99
|
+
```
|
100
|
+
|
101
|
+
*Note*: You may need to expose more then just port 8080 e.g. if you use the `zone_transfer_server` which can be done by appending additional `-p 5353:5353` flags to the `docker run` command.
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
## Using dyndnsd.rb with any nameserver via DNS zone transfers (AXFR)
|
106
|
+
|
107
|
+
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.
|
108
|
+
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.
|
109
|
+
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.
|
110
|
+
|
111
|
+
This approach has several advantages:
|
112
|
+
- dyndnsd.rb can be used in *hidden primary* fashion isolated from client's DNS traffic and does not need to implement full nameserver features
|
113
|
+
- 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
|
114
|
+
- any nameserver(s) and dyndnsd.rb do not need to be located on the same host
|
115
|
+
|
116
|
+
Example dyndnsd.rb configuration:
|
117
|
+
|
118
|
+
```yaml
|
119
|
+
host: "0.0.0.0"
|
120
|
+
port: 8245 # the DynDNS.com alternative HTTP port
|
121
|
+
db: "/opt/dyndnsd/db.json"
|
122
|
+
domain: "dyn.example.org"
|
123
|
+
updater:
|
124
|
+
name: "zone_transfer_server"
|
125
|
+
params:
|
126
|
+
# endpoint(s) to listen for incoming zone transfer (AXFR) requests, default 0.0.0.0@53
|
127
|
+
server_listens:
|
128
|
+
- 127.0.0.1@5300
|
129
|
+
# where to send DNS NOTIFY request(s) to on zone content change
|
130
|
+
send_notifies:
|
131
|
+
- '127.0.0.1'
|
132
|
+
# TTL for all records in the zone (in seconds)
|
133
|
+
zone_ttl: 300 # 5m
|
134
|
+
# zone's NS record(s) (at least one)
|
135
|
+
zone_nameservers:
|
136
|
+
- "dns.example.org."
|
137
|
+
# info for zone's SOA record
|
138
|
+
zone_email_address: "admin.example.org."
|
139
|
+
# zone's additional A/AAAA records
|
140
|
+
zone_additional_ips:
|
141
|
+
- "127.0.0.1"
|
142
|
+
users:
|
143
|
+
foo:
|
144
|
+
password: "secret"
|
145
|
+
hosts:
|
146
|
+
- foo.example.org
|
147
|
+
```
|
148
|
+
|
62
149
|
|
63
|
-
## Using dyndnsd.rb with [NSD](https://www.nlnetlabs.nl/nsd/)
|
150
|
+
## Using dyndnsd.rb with [NSD](https://www.nlnetlabs.nl/projects/nsd/about/)
|
64
151
|
|
65
|
-
NSD is a nice
|
152
|
+
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.
|
66
153
|
|
67
|
-
A feature NSD is lacking is the [Dynamic DNS update](https://tools.ietf.org/html/rfc2136) functionality BIND offers but one can fake it using the following dyndnsd.rb
|
154
|
+
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
155
|
|
69
156
|
```yaml
|
70
157
|
host: "0.0.0.0"
|
71
|
-
port:
|
158
|
+
port: 8245 # the DynDNS.com alternative HTTP port
|
72
159
|
db: "/opt/dyndnsd/db.json"
|
73
160
|
domain: "dyn.example.org"
|
74
161
|
updater:
|
@@ -88,17 +175,20 @@ users:
|
|
88
175
|
foo:
|
89
176
|
password: "secret"
|
90
177
|
hosts:
|
91
|
-
- foo.example.org
|
178
|
+
- foo.example.org
|
92
179
|
```
|
93
180
|
|
94
181
|
Start dyndnsd.rb before NSD to make sure the zone file exists else NSD complains.
|
95
182
|
|
183
|
+
|
96
184
|
## Using dyndnsd.rb with X
|
97
185
|
|
98
186
|
Please provide ideas if you are using dyndnsd.rb with other DNS servers :)
|
99
187
|
|
188
|
+
|
100
189
|
## Advanced topics
|
101
190
|
|
191
|
+
|
102
192
|
### Update URL
|
103
193
|
|
104
194
|
The update URL you want to tell your clients (humans or scripts ^^) consists of the following
|
@@ -111,10 +201,11 @@ where:
|
|
111
201
|
* USER and PASSWORD are needed for HTTP Basic Auth and valid combinations are defined in your config.yaml
|
112
202
|
* DOMAIN should match what you defined in your config.yaml as domain but may be anything else when using a webserver as proxy
|
113
203
|
* PORT depends on your (webserver/proxy) settings
|
114
|
-
* HOSTNAMES is a required list of comma
|
204
|
+
* 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
205
|
* MYIP is optional and the HTTP client's IP address will be used if missing
|
116
206
|
* MYIP6 is optional but if present also requires presence of MYIP
|
117
207
|
|
208
|
+
|
118
209
|
### IP address determination
|
119
210
|
|
120
211
|
The following rules apply:
|
@@ -123,15 +214,20 @@ The following rules apply:
|
|
123
214
|
* use any IP address provided via the X-Real-IP header e.g. when used behind HTTP reverse proxy such as nginx, or
|
124
215
|
* use any IP address used by the connecting HTTP client
|
125
216
|
|
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.
|
217
|
+
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.
|
218
|
+
|
127
219
|
|
128
220
|
### SSL, multiple listen ports
|
129
221
|
|
130
222
|
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
223
|
|
132
|
-
### Init scripts
|
133
224
|
|
134
|
-
|
225
|
+
### Startup
|
226
|
+
|
227
|
+
There is a [Dockerfile](docs/Dockerfile) that can be used to build a Docker image for running dyndnsd.rb.
|
228
|
+
|
229
|
+
The [Debian 6 init.d script](docs/debian-6-init-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.
|
230
|
+
|
135
231
|
|
136
232
|
### Monitoring
|
137
233
|
|
@@ -139,7 +235,7 @@ For monitoring dyndnsd.rb uses the [metriks](https://github.com/eric/metriks) fr
|
|
139
235
|
|
140
236
|
```yaml
|
141
237
|
host: "0.0.0.0"
|
142
|
-
port:
|
238
|
+
port: 8245 # the DynDNS.com alternative HTTP port
|
143
239
|
db: "/opt/dyndnsd/db.json"
|
144
240
|
domain: "dyn.example.org"
|
145
241
|
# configure the Graphite backend to be used instead of proctitle
|
@@ -172,14 +268,16 @@ users:
|
|
172
268
|
password: "ihavenohosts"
|
173
269
|
```
|
174
270
|
|
271
|
+
|
175
272
|
### Tracing (experimental)
|
176
273
|
|
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.
|
274
|
+
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.
|
275
|
+
|
178
276
|
Currently only one OpenTracing-compatible tracer implementation named [CNCF Jaeger](https://github.com/jaegertracing/jaeger) can be configured to use with dyndnsd.rb.
|
179
277
|
|
180
278
|
```yaml
|
181
279
|
host: "0.0.0.0"
|
182
|
-
port:
|
280
|
+
port: 8245 # the DynDNS.com alternative HTTP port
|
183
281
|
db: "/opt/dyndnsd/db.json"
|
184
282
|
domain: "dyn.example.org"
|
185
283
|
# enable and configure tracing using the (currently only) tracer jaeger
|
@@ -210,6 +308,7 @@ users:
|
|
210
308
|
password: "ihavenohosts"
|
211
309
|
```
|
212
310
|
|
311
|
+
|
213
312
|
## License
|
214
313
|
|
215
314
|
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,5 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'date'
|
3
4
|
require 'etc'
|
4
5
|
require 'logger'
|
5
6
|
require 'ipaddr'
|
@@ -13,6 +14,7 @@ require 'rack/tracer'
|
|
13
14
|
|
14
15
|
require 'dyndnsd/generator/bind'
|
15
16
|
require 'dyndnsd/updater/command_with_bind_zone'
|
17
|
+
require 'dyndnsd/updater/zone_transfer_server'
|
16
18
|
require 'dyndnsd/responder/dyndns_style'
|
17
19
|
require 'dyndnsd/responder/rest_style'
|
18
20
|
require 'dyndnsd/database'
|
@@ -56,9 +58,9 @@ module Dyndnsd
|
|
56
58
|
@db.load
|
57
59
|
@db['serial'] ||= 1
|
58
60
|
@db['hosts'] ||= {}
|
61
|
+
@updater.update(@db)
|
59
62
|
if @db.changed?
|
60
63
|
@db.save
|
61
|
-
@updater.update(@db)
|
62
64
|
end
|
63
65
|
end
|
64
66
|
|
@@ -79,7 +81,7 @@ module Dyndnsd
|
|
79
81
|
end
|
80
82
|
|
81
83
|
# @param env [Hash{String => String}]
|
82
|
-
# @return [Array{Integer,Hash{String => String},Array
|
84
|
+
# @return [Array{Integer,Hash{String => String},Array<String>}]
|
83
85
|
def call(env)
|
84
86
|
return [422, {'X-DynDNS-Response' => 'method_forbidden'}, []] if env['REQUEST_METHOD'] != 'GET'
|
85
87
|
return [422, {'X-DynDNS-Response' => 'not_found'}, []] if env['PATH_INFO'] != '/nic/update'
|
@@ -133,7 +135,7 @@ module Dyndnsd
|
|
133
135
|
private
|
134
136
|
|
135
137
|
# @param params [Hash{String => String}]
|
136
|
-
# @return [Array
|
138
|
+
# @return [Array<String>]
|
137
139
|
def extract_v4_and_v6_address(params)
|
138
140
|
return [] if !(params['myip'])
|
139
141
|
begin
|
@@ -147,7 +149,7 @@ module Dyndnsd
|
|
147
149
|
|
148
150
|
# @param env [Hash{String => String}]
|
149
151
|
# @param params [Hash{String => String}]
|
150
|
-
# @return [Array
|
152
|
+
# @return [Array<String>]
|
151
153
|
def extract_myips(env, params)
|
152
154
|
# require presence of myip parameter as valid IPAddr (v4) and valid myip6
|
153
155
|
return extract_v4_and_v6_address(params) if params.key?('myip6')
|
@@ -163,8 +165,8 @@ module Dyndnsd
|
|
163
165
|
end
|
164
166
|
|
165
167
|
# @param hostnames [String]
|
166
|
-
# @param myips [Array
|
167
|
-
# @return [Array
|
168
|
+
# @param myips [Array<String>]
|
169
|
+
# @return [Array<Symbol>]
|
168
170
|
def process_changes(hostnames, myips)
|
169
171
|
changes = []
|
170
172
|
Helper.span('process_changes') do |span|
|
@@ -193,13 +195,13 @@ module Dyndnsd
|
|
193
195
|
def update_db
|
194
196
|
@db['serial'] += 1
|
195
197
|
Dyndnsd.logger.info "Committing update ##{@db['serial']}"
|
196
|
-
@db.save
|
197
198
|
@updater.update(@db)
|
199
|
+
@db.save
|
198
200
|
Metriks.meter('updates.committed').mark
|
199
201
|
end
|
200
202
|
|
201
203
|
# @param env [Hash{String => String}]
|
202
|
-
# @return [Array{Integer,Hash{String => String},Array
|
204
|
+
# @return [Array{Integer,Hash{String => String},Array<String>}]
|
203
205
|
def handle_dyndns_request(env)
|
204
206
|
params = Rack::Utils.parse_query(env['QUERY_STRING'])
|
205
207
|
|
@@ -244,21 +246,20 @@ module Dyndnsd
|
|
244
246
|
if config['logfile']
|
245
247
|
Dyndnsd.logger = Logger.new(config['logfile'])
|
246
248
|
else
|
247
|
-
Dyndnsd.logger = Logger.new(
|
249
|
+
Dyndnsd.logger = Logger.new($stdout)
|
248
250
|
end
|
249
251
|
|
250
252
|
Dyndnsd.logger.progname = 'dyndnsd'
|
251
253
|
Dyndnsd.logger.formatter = LogFormatter.new
|
254
|
+
Dyndnsd.logger.level = config['debug'] ? Logger::DEBUG : Logger::INFO
|
252
255
|
end
|
253
256
|
|
254
257
|
# @return [void]
|
255
258
|
private_class_method def self.setup_traps
|
256
259
|
Signal.trap('INT') do
|
257
|
-
Dyndnsd.logger.info 'Quitting...'
|
258
260
|
Rack::Handler::WEBrick.shutdown
|
259
261
|
end
|
260
262
|
Signal.trap('TERM') do
|
261
|
-
Dyndnsd.logger.info 'Quitting...'
|
262
263
|
Rack::Handler::WEBrick.shutdown
|
263
264
|
end
|
264
265
|
end
|
@@ -313,7 +314,12 @@ module Dyndnsd
|
|
313
314
|
private_class_method def self.setup_rack(config)
|
314
315
|
# configure daemon
|
315
316
|
db = Database.new(config['db'])
|
316
|
-
|
317
|
+
case config.dig('updater', 'name')
|
318
|
+
when 'command_with_bind_zone'
|
319
|
+
updater = Updater::CommandWithBindZone.new(config['domain'], config.dig('updater', 'params'))
|
320
|
+
when 'zone_transfer_server'
|
321
|
+
updater = Updater::ZoneTransferServer.new(config['domain'], config.dig('updater', 'params'))
|
322
|
+
end
|
317
323
|
daemon = Daemon.new(config, db, updater)
|
318
324
|
|
319
325
|
# configure rack
|
data/lib/dyndnsd/database.rb
CHANGED
@@ -1,15 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
module Dyndnsd
|
3
4
|
module Generator
|
4
5
|
class Bind
|
5
6
|
# @param domain [String]
|
6
|
-
# @param
|
7
|
-
def initialize(domain,
|
7
|
+
# @param updater_params [Hash{String => Object}]
|
8
|
+
def initialize(domain, updater_params)
|
8
9
|
@domain = domain
|
9
|
-
@ttl =
|
10
|
-
@dns =
|
11
|
-
@email_addr =
|
12
|
-
@additional_zone_content =
|
10
|
+
@ttl = updater_params['ttl']
|
11
|
+
@dns = updater_params['dns']
|
12
|
+
@email_addr = updater_params['email_addr']
|
13
|
+
@additional_zone_content = updater_params['additional_zone_content']
|
13
14
|
end
|
14
15
|
|
15
16
|
# @param db [Dyndnsd::Database]
|
@@ -26,7 +27,7 @@ module Dyndnsd
|
|
26
27
|
ips.each do |ip|
|
27
28
|
ip = IPAddr.new(ip).native
|
28
29
|
type = ip.ipv6? ? 'AAAA' : 'A'
|
29
|
-
name = hostname.chomp(
|
30
|
+
name = hostname.chomp(".#{@domain}")
|
30
31
|
out << "#{name} IN #{type} #{ip}"
|
31
32
|
end
|
32
33
|
end
|