dyndnsd 2.1.0 → 3.0.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 +32 -0
- data/README.md +78 -16
- data/exe/dyndnsd +6 -0
- data/lib/dyndnsd.rb +19 -8
- data/lib/dyndnsd/database.rb +2 -1
- data/lib/dyndnsd/generator/bind.rb +7 -6
- data/lib/dyndnsd/helper.rb +2 -1
- data/lib/dyndnsd/responder/dyndns_style.rb +7 -4
- data/lib/dyndnsd/responder/rest_style.rb +7 -4
- data/lib/dyndnsd/textfile_reporter.rb +4 -5
- data/lib/dyndnsd/updater/command_with_bind_zone.rb +11 -7
- data/lib/dyndnsd/updater/zone_transfer_server.rb +158 -0
- data/lib/dyndnsd/version.rb +2 -1
- metadata +46 -54
- 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/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: 7b67c4c48580887dc15c4149ee49c91d803c1e187a7dee25a5e930ff7efd4086
|
4
|
+
data.tar.gz: a0090df181a91d797e7eb65c18f5d76c68cebcfbfa976319bc37d7dc227ca6e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 636cd3cb95d49f5a84e43c82d29a271c40686bae24609e5781c052d5454ceec6431bb3e470cf7aa665de8ccbee9285dab8000e7b264c0c265e3361a4cf9b9f17
|
7
|
+
data.tar.gz: da40bc71a2b92481977ad3820643a19b3ce6ff9b9d1ed5e22328796bd42e0aa8a44b015407642651e8e6b4215a4a4dd60797a60f6cb929c18595814000027acf
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,37 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 3.0.0 (July 29, 2020)
|
4
|
+
|
5
|
+
IMPROVEMENTS:
|
6
|
+
|
7
|
+
- Drop EOL Ruby 2.4 and lower support, now minimum version supported is Ruby 2.5
|
8
|
+
|
9
|
+
## 2.3.1 (July 27, 2020)
|
10
|
+
|
11
|
+
IMPROVEMENTS:
|
12
|
+
|
13
|
+
- Fix annoying error message `log writing failed. can't be called from trap context` on shutdown by not attempting to log redundant information there
|
14
|
+
|
15
|
+
## 2.3.0 (July 20, 2020)
|
16
|
+
|
17
|
+
IMPROVEMENTS:
|
18
|
+
|
19
|
+
- Allow enabling debug logging
|
20
|
+
- 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
|
21
|
+
|
22
|
+
## 2.2.0 (March 6, 2020)
|
23
|
+
|
24
|
+
IMPROVEMENTS:
|
25
|
+
|
26
|
+
- 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
|
27
|
+
- Adopt Ruby 2.3 frozen string literals for source code potentially reducing memory consumption
|
28
|
+
|
29
|
+
## 2.1.1 (March 1, 2020)
|
30
|
+
|
31
|
+
IMPROVEMENTS:
|
32
|
+
|
33
|
+
- Fix potential `nil` cases detected by [Sorbet](https://sorbet.org) including refactorings
|
34
|
+
|
3
35
|
## 2.1.0 (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
|
@@ -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'
|
@@ -56,9 +57,9 @@ module Dyndnsd
|
|
56
57
|
@db.load
|
57
58
|
@db['serial'] ||= 1
|
58
59
|
@db['hosts'] ||= {}
|
60
|
+
@updater.update(@db)
|
59
61
|
if @db.changed?
|
60
62
|
@db.save
|
61
|
-
@updater.update(@db)
|
62
63
|
end
|
63
64
|
end
|
64
65
|
|
@@ -112,8 +113,14 @@ module Dyndnsd
|
|
112
113
|
|
113
114
|
# drop priviliges as soon as possible
|
114
115
|
# NOTE: first change group than user
|
115
|
-
|
116
|
-
|
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
|
117
124
|
|
118
125
|
setup_traps
|
119
126
|
|
@@ -187,8 +194,8 @@ module Dyndnsd
|
|
187
194
|
def update_db
|
188
195
|
@db['serial'] += 1
|
189
196
|
Dyndnsd.logger.info "Committing update ##{@db['serial']}"
|
190
|
-
@db.save
|
191
197
|
@updater.update(@db)
|
198
|
+
@db.save
|
192
199
|
Metriks.meter('updates.committed').mark
|
193
200
|
end
|
194
201
|
|
@@ -243,16 +250,15 @@ module Dyndnsd
|
|
243
250
|
|
244
251
|
Dyndnsd.logger.progname = 'dyndnsd'
|
245
252
|
Dyndnsd.logger.formatter = LogFormatter.new
|
253
|
+
Dyndnsd.logger.level = config['debug'] ? Logger::DEBUG : Logger::INFO
|
246
254
|
end
|
247
255
|
|
248
256
|
# @return [void]
|
249
257
|
private_class_method def self.setup_traps
|
250
258
|
Signal.trap('INT') do
|
251
|
-
Dyndnsd.logger.info 'Quitting...'
|
252
259
|
Rack::Handler::WEBrick.shutdown
|
253
260
|
end
|
254
261
|
Signal.trap('TERM') do
|
255
|
-
Dyndnsd.logger.info 'Quitting...'
|
256
262
|
Rack::Handler::WEBrick.shutdown
|
257
263
|
end
|
258
264
|
end
|
@@ -307,7 +313,12 @@ module Dyndnsd
|
|
307
313
|
private_class_method def self.setup_rack(config)
|
308
314
|
# configure daemon
|
309
315
|
db = Database.new(config['db'])
|
310
|
-
|
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
|
311
322
|
daemon = Daemon.new(config, db, updater)
|
312
323
|
|
313
324
|
# configure rack
|
data/lib/dyndnsd/database.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
require 'forwardable'
|
3
4
|
|
@@ -15,7 +16,7 @@ module Dyndnsd
|
|
15
16
|
# @return [void]
|
16
17
|
def load
|
17
18
|
if File.file?(@db_file)
|
18
|
-
@db = JSON.parse(File.
|
19
|
+
@db = JSON.parse(File.read(@db_file, mode: 'r'))
|
19
20
|
else
|
20
21
|
@db = {}
|
21
22
|
end
|
@@ -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]
|
data/lib/dyndnsd/helper.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
require 'ipaddr'
|
3
4
|
|
@@ -57,7 +58,7 @@ module Dyndnsd
|
|
57
58
|
'error.kind': e.class.to_s,
|
58
59
|
'error.object': e,
|
59
60
|
message: e.message,
|
60
|
-
stack: e.backtrace
|
61
|
+
stack: e.backtrace&.join("\n") || ''
|
61
62
|
)
|
62
63
|
raise
|
63
64
|
ensure
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
module Dyndnsd
|
3
4
|
module Responder
|
@@ -26,9 +27,10 @@ module Dyndnsd
|
|
26
27
|
# @param body [Array{String}]
|
27
28
|
# @return [Array{Integer,Hash{String => String},Array{String}}]
|
28
29
|
def decorate_dyndnsd_response(status_code, headers, body)
|
29
|
-
|
30
|
+
case status_code
|
31
|
+
when 200
|
30
32
|
[200, {'Content-Type' => 'text/plain'}, [get_success_body(body[0], body[1])]]
|
31
|
-
|
33
|
+
when 422
|
32
34
|
error_response_map[headers['X-DynDNS-Response']]
|
33
35
|
end
|
34
36
|
end
|
@@ -38,9 +40,10 @@ module Dyndnsd
|
|
38
40
|
# @param _body [Array{String}]
|
39
41
|
# @return [Array{Integer,Hash{String => String},Array{String}}]
|
40
42
|
def decorate_other_response(status_code, headers, _body)
|
41
|
-
|
43
|
+
case status_code
|
44
|
+
when 400
|
42
45
|
[status_code, headers, ['Bad Request']]
|
43
|
-
|
46
|
+
when 401
|
44
47
|
[status_code, headers, ['badauth']]
|
45
48
|
end
|
46
49
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
module Dyndnsd
|
3
4
|
module Responder
|
@@ -26,9 +27,10 @@ module Dyndnsd
|
|
26
27
|
# @param body [Array{String}]
|
27
28
|
# @return [Array{Integer,Hash{String => String},Array{String}}]
|
28
29
|
def decorate_dyndnsd_response(status_code, headers, body)
|
29
|
-
|
30
|
+
case status_code
|
31
|
+
when 200
|
30
32
|
[200, {'Content-Type' => 'text/plain'}, [get_success_body(body[0], body[1])]]
|
31
|
-
|
33
|
+
when 422
|
32
34
|
error_response_map[headers['X-DynDNS-Response']]
|
33
35
|
end
|
34
36
|
end
|
@@ -38,9 +40,10 @@ module Dyndnsd
|
|
38
40
|
# @param _body [Array{String}]
|
39
41
|
# @return [Array{Integer,Hash{String => String},Array{String}}]
|
40
42
|
def decorate_other_response(status_code, headers, _body)
|
41
|
-
|
43
|
+
case status_code
|
44
|
+
when 400
|
42
45
|
[status_code, headers, ['Bad Request']]
|
43
|
-
|
46
|
+
when 401
|
44
47
|
[status_code, headers, ['Unauthorized']]
|
45
48
|
end
|
46
49
|
end
|