dyndnsd 2.0.0 → 2.1.0
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/.gitignore +1 -0
- data/.rubocop.yml +17 -10
- data/.solargraph.yml +16 -0
- data/.travis.yml +9 -5
- data/CHANGELOG.md +9 -1
- data/Rakefile +12 -0
- data/dyndnsd.gemspec +4 -3
- data/lib/dyndnsd/database.rb +4 -0
- data/lib/dyndnsd/generator/bind.rb +4 -0
- data/lib/dyndnsd/helper.rb +16 -0
- data/lib/dyndnsd/responder/dyndns_style.rb +15 -0
- data/lib/dyndnsd/responder/rest_style.rb +15 -0
- data/lib/dyndnsd/textfile_reporter.rb +13 -0
- data/lib/dyndnsd/updater/command_with_bind_zone.rb +6 -2
- data/lib/dyndnsd/version.rb +1 -1
- data/lib/dyndnsd.rb +38 -1
- metadata +22 -9
- data/.rubocop_todo.yml +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52b78d9faf8be67cd76202d2f6060ee5f6b96c382603d7431f906a5b03b3c468
|
4
|
+
data.tar.gz: 889f266280f47c44418fca138d5253f1eaee7ef5ab79555d96e76b455d74d029
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72c3cb12a042ebbc9c5ccb8ee00d6278165e5f25acc00e0666793e9ed0bae8bffbcb9057b63fbf7d4ed22c696fee664ce0ffd872c554042ec098437df6853181
|
7
|
+
data.tar.gz: 44dae96b17ce80eaf60de42bf5ae30444b911659c779182598bd06ce5d936db55d672c5c1b846deb76e911752b81b2613ae3d5eebb4d823631deb49ca4473f29
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,14 +1,9 @@
|
|
1
|
-
inherit_from: .rubocop_todo.yml
|
2
|
-
|
3
1
|
AllCops:
|
4
2
|
TargetRubyVersion: '2.3'
|
5
3
|
|
6
4
|
Gemspec/OrderedDependencies:
|
7
5
|
Enabled: false
|
8
6
|
|
9
|
-
Layout/AlignHash:
|
10
|
-
Enabled: false
|
11
|
-
|
12
7
|
Layout/EmptyLineAfterGuardClause:
|
13
8
|
Enabled: false
|
14
9
|
|
@@ -16,9 +11,15 @@ Layout/EmptyLineAfterGuardClause:
|
|
16
11
|
Layout/EmptyLinesAroundArguments:
|
17
12
|
Enabled: false
|
18
13
|
|
19
|
-
Layout/
|
14
|
+
Layout/HashAlignment:
|
20
15
|
Enabled: false
|
21
16
|
|
17
|
+
Layout/LeadingEmptyLines:
|
18
|
+
Enabled: false
|
19
|
+
|
20
|
+
Layout/LineLength:
|
21
|
+
Max: 200
|
22
|
+
|
22
23
|
Layout/SpaceInsideHashLiteralBraces:
|
23
24
|
Enabled: false
|
24
25
|
|
@@ -34,16 +35,13 @@ Metrics/ClassLength:
|
|
34
35
|
Metrics/CyclomaticComplexity:
|
35
36
|
Enabled: false
|
36
37
|
|
37
|
-
Metrics/LineLength:
|
38
|
-
Max: 200
|
39
|
-
|
40
38
|
Metrics/MethodLength:
|
41
39
|
Enabled: false
|
42
40
|
|
43
41
|
Metrics/PerceivedComplexity:
|
44
42
|
Enabled: false
|
45
43
|
|
46
|
-
Naming/
|
44
|
+
Naming/MethodParameterName:
|
47
45
|
Enabled: false
|
48
46
|
|
49
47
|
Naming/MemoizedInstanceVariableName:
|
@@ -64,6 +62,15 @@ Style/FrozenStringLiteralComment:
|
|
64
62
|
Style/GuardClause:
|
65
63
|
Enabled: false
|
66
64
|
|
65
|
+
Style/HashEachMethods:
|
66
|
+
Enabled: true
|
67
|
+
|
68
|
+
Style/HashTransformKeys:
|
69
|
+
Enabled: true
|
70
|
+
|
71
|
+
Style/HashTransformValues:
|
72
|
+
Enabled: true
|
73
|
+
|
67
74
|
Style/IdenticalConditionalBranches:
|
68
75
|
Enabled: false
|
69
76
|
|
data/.solargraph.yml
ADDED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 2.1.0 (March 1, 2020)
|
4
|
+
|
5
|
+
IMPROVEMENTS:
|
6
|
+
|
7
|
+
- Add Ruby 2.7 support
|
8
|
+
- 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)
|
9
|
+
- Document code using YARD tags, e.g. for type information and better code completion
|
10
|
+
|
3
11
|
## 2.0.0 (January 25, 2019)
|
4
12
|
|
5
13
|
IMPROVEMENTS:
|
@@ -9,7 +17,7 @@ IMPROVEMENTS:
|
|
9
17
|
- Better code maintainability by refactorings
|
10
18
|
- Update dependencies, mainly `rack` to new major version 2
|
11
19
|
- Add Ruby 2.5 and Ruby 2.6 support
|
12
|
-
- Add experimental [OpenTracing](
|
20
|
+
- Add experimental [OpenTracing](https://opentracing.io/) support with [CNCF Jaeger](https://github.com/jaegertracing/jaeger)
|
13
21
|
- Support host offlining by deleting the associated DNS records
|
14
22
|
- Add textfile reporter to write Graphite-style metrics (also compatible with [Prometheus](https://prometheus.io/)) into a file
|
15
23
|
|
data/Rakefile
CHANGED
@@ -7,4 +7,16 @@ RSpec::Core::RakeTask.new(:spec)
|
|
7
7
|
RuboCop::RakeTask.new
|
8
8
|
Bundler::Audit::Task.new
|
9
9
|
|
10
|
+
desc 'Should be run by developer once to prepare initial solargraph usage (fill caches etc.)'
|
11
|
+
task :'solargraph:init' do
|
12
|
+
sh 'solargraph download-core'
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'Run experimental solargraph type checker'
|
16
|
+
task :'solargraph:tc' do
|
17
|
+
sh 'solargraph typecheck'
|
18
|
+
end
|
19
|
+
|
10
20
|
task default: [:rubocop, :spec, 'bundle:audit']
|
21
|
+
|
22
|
+
task travis: [:default, :'solargraph:tc']
|
data/dyndnsd.gemspec
CHANGED
@@ -24,13 +24,14 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.add_runtime_dependency 'json'
|
25
25
|
s.add_runtime_dependency 'metriks'
|
26
26
|
s.add_runtime_dependency 'opentracing', '~> 0.5.0'
|
27
|
-
s.add_runtime_dependency 'rack-tracer', '~> 0.
|
27
|
+
s.add_runtime_dependency 'rack-tracer', '~> 0.9.0'
|
28
28
|
s.add_runtime_dependency 'jaeger-client', '~> 0.10.0'
|
29
29
|
|
30
30
|
s.add_development_dependency 'bundler'
|
31
31
|
s.add_development_dependency 'rake'
|
32
32
|
s.add_development_dependency 'rspec'
|
33
33
|
s.add_development_dependency 'rack-test'
|
34
|
-
s.add_development_dependency 'rubocop', '~> 0.
|
35
|
-
s.add_development_dependency 'bundler-audit'
|
34
|
+
s.add_development_dependency 'rubocop', '~> 0.80.0'
|
35
|
+
s.add_development_dependency 'bundler-audit', '~> 0.6.0'
|
36
|
+
s.add_development_dependency 'solargraph'
|
36
37
|
end
|
data/lib/dyndnsd/database.rb
CHANGED
@@ -7,10 +7,12 @@ module Dyndnsd
|
|
7
7
|
|
8
8
|
def_delegators :@db, :[], :[]=, :each, :has_key?
|
9
9
|
|
10
|
+
# @param db_file [String]
|
10
11
|
def initialize(db_file)
|
11
12
|
@db_file = db_file
|
12
13
|
end
|
13
14
|
|
15
|
+
# @return [void]
|
14
16
|
def load
|
15
17
|
if File.file?(@db_file)
|
16
18
|
@db = JSON.parse(File.open(@db_file, 'r', &:read))
|
@@ -20,6 +22,7 @@ module Dyndnsd
|
|
20
22
|
@db_hash = @db.hash
|
21
23
|
end
|
22
24
|
|
25
|
+
# @return [void]
|
23
26
|
def save
|
24
27
|
Helper.span('database_save') do |_span|
|
25
28
|
File.open(@db_file, 'w') { |f| JSON.dump(@db, f) }
|
@@ -27,6 +30,7 @@ module Dyndnsd
|
|
27
30
|
end
|
28
31
|
end
|
29
32
|
|
33
|
+
# @return [Boolean]
|
30
34
|
def changed?
|
31
35
|
@db_hash != @db.hash
|
32
36
|
end
|
@@ -2,6 +2,8 @@
|
|
2
2
|
module Dyndnsd
|
3
3
|
module Generator
|
4
4
|
class Bind
|
5
|
+
# @param domain [String]
|
6
|
+
# @param config [Hash{String => Object}]
|
5
7
|
def initialize(domain, config)
|
6
8
|
@domain = domain
|
7
9
|
@ttl = config['ttl']
|
@@ -10,6 +12,8 @@ module Dyndnsd
|
|
10
12
|
@additional_zone_content = config['additional_zone_content']
|
11
13
|
end
|
12
14
|
|
15
|
+
# @param db [Dyndnsd::Database]
|
16
|
+
# @return [String]
|
13
17
|
def generate(db)
|
14
18
|
out = []
|
15
19
|
out << "$TTL #{@ttl}"
|
data/lib/dyndnsd/helper.rb
CHANGED
@@ -3,6 +3,9 @@ require 'ipaddr'
|
|
3
3
|
|
4
4
|
module Dyndnsd
|
5
5
|
class Helper
|
6
|
+
# @param hostname [String]
|
7
|
+
# @param domain [String]
|
8
|
+
# @return [Boolean]
|
6
9
|
def self.fqdn_valid?(hostname, domain)
|
7
10
|
return false if hostname.length < domain.length + 2
|
8
11
|
return false if !hostname.end_with?(domain)
|
@@ -11,6 +14,8 @@ module Dyndnsd
|
|
11
14
|
true
|
12
15
|
end
|
13
16
|
|
17
|
+
# @param ip [String]
|
18
|
+
# @return [Boolean]
|
14
19
|
def self.ip_valid?(ip)
|
15
20
|
IPAddr.new(ip)
|
16
21
|
true
|
@@ -18,15 +23,26 @@ module Dyndnsd
|
|
18
23
|
false
|
19
24
|
end
|
20
25
|
|
26
|
+
# @param username [String]
|
27
|
+
# @param password [String]
|
28
|
+
# @param users [Hash]
|
29
|
+
# @return [Boolean]
|
21
30
|
def self.user_allowed?(username, password, users)
|
22
31
|
(users.key? username) && (users[username]['password'] == password)
|
23
32
|
end
|
24
33
|
|
34
|
+
# @param hostname [String]
|
35
|
+
# @param myips [Array]
|
36
|
+
# @param hosts [Hash]
|
37
|
+
# @return [Boolean]
|
25
38
|
def self.changed?(hostname, myips, hosts)
|
26
39
|
# myips order is always deterministic
|
27
40
|
((!hosts.include? hostname) || (hosts[hostname] != myips)) && !myips.empty?
|
28
41
|
end
|
29
42
|
|
43
|
+
# @param operation [String]
|
44
|
+
# @param block [Proc]
|
45
|
+
# @return [void]
|
30
46
|
def self.span(operation, &block)
|
31
47
|
scope = OpenTracing.start_active_span(operation)
|
32
48
|
span = scope.span
|
@@ -2,10 +2,13 @@
|
|
2
2
|
module Dyndnsd
|
3
3
|
module Responder
|
4
4
|
class DynDNSStyle
|
5
|
+
# @param app [#call]
|
5
6
|
def initialize(app)
|
6
7
|
@app = app
|
7
8
|
end
|
8
9
|
|
10
|
+
# @param env [Hash{String => String}]
|
11
|
+
# @return [Array{Integer,Hash{String => String},Array{String}}]
|
9
12
|
def call(env)
|
10
13
|
@app.call(env).tap do |status_code, headers, body|
|
11
14
|
if headers.key?('X-DynDNS-Response')
|
@@ -18,6 +21,10 @@ module Dyndnsd
|
|
18
21
|
|
19
22
|
private
|
20
23
|
|
24
|
+
# @param status_code [Integer]
|
25
|
+
# @param headers [Hash{String => String}]
|
26
|
+
# @param body [Array{String}]
|
27
|
+
# @return [Array{Integer,Hash{String => String},Array{String}}]
|
21
28
|
def decorate_dyndnsd_response(status_code, headers, body)
|
22
29
|
if status_code == 200
|
23
30
|
[200, {'Content-Type' => 'text/plain'}, [get_success_body(body[0], body[1])]]
|
@@ -26,6 +33,10 @@ module Dyndnsd
|
|
26
33
|
end
|
27
34
|
end
|
28
35
|
|
36
|
+
# @param status_code [Integer]
|
37
|
+
# @param headers [Hash{String => String}]
|
38
|
+
# @param _body [Array{String}]
|
39
|
+
# @return [Array{Integer,Hash{String => String},Array{String}}]
|
29
40
|
def decorate_other_response(status_code, headers, _body)
|
30
41
|
if status_code == 400
|
31
42
|
[status_code, headers, ['Bad Request']]
|
@@ -34,10 +45,14 @@ module Dyndnsd
|
|
34
45
|
end
|
35
46
|
end
|
36
47
|
|
48
|
+
# @param changes [Array{Symbol}]
|
49
|
+
# @param myips [Array{String}]
|
50
|
+
# @return [String]
|
37
51
|
def get_success_body(changes, myips)
|
38
52
|
changes.map { |change| "#{change} #{myips.join(' ')}" }.join("\n")
|
39
53
|
end
|
40
54
|
|
55
|
+
# @return [Hash{String => Object}]
|
41
56
|
def error_response_map
|
42
57
|
{
|
43
58
|
# general http errors
|
@@ -2,10 +2,13 @@
|
|
2
2
|
module Dyndnsd
|
3
3
|
module Responder
|
4
4
|
class RestStyle
|
5
|
+
# @param app [#call]
|
5
6
|
def initialize(app)
|
6
7
|
@app = app
|
7
8
|
end
|
8
9
|
|
10
|
+
# @param env [Hash{String => String}]
|
11
|
+
# @return [Array{Integer,Hash{String => String},Array{String}}]
|
9
12
|
def call(env)
|
10
13
|
@app.call(env).tap do |status_code, headers, body|
|
11
14
|
if headers.key?('X-DynDNS-Response')
|
@@ -18,6 +21,10 @@ module Dyndnsd
|
|
18
21
|
|
19
22
|
private
|
20
23
|
|
24
|
+
# @param status_code [Integer]
|
25
|
+
# @param headers [Hash{String => String}]
|
26
|
+
# @param body [Array{String}]
|
27
|
+
# @return [Array{Integer,Hash{String => String},Array{String}}]
|
21
28
|
def decorate_dyndnsd_response(status_code, headers, body)
|
22
29
|
if status_code == 200
|
23
30
|
[200, {'Content-Type' => 'text/plain'}, [get_success_body(body[0], body[1])]]
|
@@ -26,6 +33,10 @@ module Dyndnsd
|
|
26
33
|
end
|
27
34
|
end
|
28
35
|
|
36
|
+
# @param status_code [Integer]
|
37
|
+
# @param headers [Hash{String => String}]
|
38
|
+
# @param _body [Array{String}]
|
39
|
+
# @return [Array{Integer,Hash{String => String},Array{String}}]
|
29
40
|
def decorate_other_response(status_code, headers, _body)
|
30
41
|
if status_code == 400
|
31
42
|
[status_code, headers, ['Bad Request']]
|
@@ -34,10 +45,14 @@ module Dyndnsd
|
|
34
45
|
end
|
35
46
|
end
|
36
47
|
|
48
|
+
# @param changes [Array{Symbol}]
|
49
|
+
# @param myips [Array{String}]
|
50
|
+
# @return [String]
|
37
51
|
def get_success_body(changes, myips)
|
38
52
|
changes.map { |change| change == :good ? "Changed to #{myips.join(' ')}" : "No change needed for #{myips.join(' ')}" }.join("\n")
|
39
53
|
end
|
40
54
|
|
55
|
+
# @return [Hash{String => Object}]
|
41
56
|
def error_response_map
|
42
57
|
{
|
43
58
|
# general http errors
|
@@ -5,8 +5,11 @@ require 'metriks'
|
|
5
5
|
|
6
6
|
module Dyndnsd
|
7
7
|
class TextfileReporter
|
8
|
+
# @return [String]
|
8
9
|
attr_reader :file
|
9
10
|
|
11
|
+
# @param file [String]
|
12
|
+
# @param options [Hash{Symbol => Object}]
|
10
13
|
def initialize(file, options = {})
|
11
14
|
@file = file
|
12
15
|
|
@@ -17,6 +20,7 @@ module Dyndnsd
|
|
17
20
|
@on_error = options[:on_error] || proc { |ex| }
|
18
21
|
end
|
19
22
|
|
23
|
+
# @return [void]
|
20
24
|
def start
|
21
25
|
@thread ||= Thread.new do
|
22
26
|
loop do
|
@@ -33,16 +37,19 @@ module Dyndnsd
|
|
33
37
|
end
|
34
38
|
end
|
35
39
|
|
40
|
+
# @return [void]
|
36
41
|
def stop
|
37
42
|
@thread&.kill
|
38
43
|
@thread = nil
|
39
44
|
end
|
40
45
|
|
46
|
+
# @return [void]
|
41
47
|
def restart
|
42
48
|
stop
|
43
49
|
start
|
44
50
|
end
|
45
51
|
|
52
|
+
# @return [void]
|
46
53
|
def write
|
47
54
|
File.open(@file, 'w') do |f|
|
48
55
|
@registry.each do |name, metric|
|
@@ -85,6 +92,12 @@ module Dyndnsd
|
|
85
92
|
end
|
86
93
|
end
|
87
94
|
|
95
|
+
# @param file [String]
|
96
|
+
# @param base_name [String]
|
97
|
+
# @param metric [Object]
|
98
|
+
# @param keys [Array{Symbol}]
|
99
|
+
# @param snapshot_keys [Array{Symbol}]
|
100
|
+
# @return [void]
|
88
101
|
def write_metric(file, base_name, metric, keys, snapshot_keys = [])
|
89
102
|
time = Time.now.to_i
|
90
103
|
|
@@ -2,18 +2,22 @@
|
|
2
2
|
module Dyndnsd
|
3
3
|
module Updater
|
4
4
|
class CommandWithBindZone
|
5
|
+
# @param domain [String]
|
6
|
+
# @param config [Hash{String => Object}]
|
5
7
|
def initialize(domain, config)
|
6
8
|
@zone_file = config['zone_file']
|
7
9
|
@command = config['command']
|
8
10
|
@generator = Generator::Bind.new(domain, config)
|
9
11
|
end
|
10
12
|
|
11
|
-
|
13
|
+
# @param db [Dyndnsd::Database]
|
14
|
+
# @return [void]
|
15
|
+
def update(db)
|
12
16
|
Helper.span('updater_update') do |span|
|
13
17
|
span.set_tag('dyndnsd.updater.name', self.class.name.split('::').last)
|
14
18
|
|
15
19
|
# write zone file in bind syntax
|
16
|
-
File.open(@zone_file, 'w') { |f| f.write(@generator.generate(
|
20
|
+
File.open(@zone_file, 'w') { |f| f.write(@generator.generate(db)) }
|
17
21
|
# call user-defined command
|
18
22
|
pid = fork do
|
19
23
|
exec @command
|
data/lib/dyndnsd/version.rb
CHANGED
data/lib/dyndnsd.rb
CHANGED
@@ -21,21 +21,32 @@ require 'dyndnsd/textfile_reporter'
|
|
21
21
|
require 'dyndnsd/version'
|
22
22
|
|
23
23
|
module Dyndnsd
|
24
|
+
# @return [Logger]
|
24
25
|
def self.logger
|
25
26
|
@logger
|
26
27
|
end
|
27
28
|
|
29
|
+
# @param logger [Logger]
|
30
|
+
# @return [Logger]
|
28
31
|
def self.logger=(logger)
|
29
32
|
@logger = logger
|
30
33
|
end
|
31
34
|
|
32
35
|
class LogFormatter
|
36
|
+
# @param lvl [Object]
|
37
|
+
# @param _time [DateTime]
|
38
|
+
# @param _progname [String]
|
39
|
+
# @param msg [Object]
|
40
|
+
# @return [String]
|
33
41
|
def call(lvl, _time, _progname, msg)
|
34
42
|
format("[%s] %-5s %s\n", Time.now.strftime('%Y-%m-%d %H:%M:%S'), lvl, msg.to_s)
|
35
43
|
end
|
36
44
|
end
|
37
45
|
|
38
46
|
class Daemon
|
47
|
+
# @param config [Hash{String => Object}]
|
48
|
+
# @param db [Dyndnsd::Database]
|
49
|
+
# @param updater [#update]
|
39
50
|
def initialize(config, db, updater)
|
40
51
|
@users = config['users']
|
41
52
|
@domain = config['domain']
|
@@ -51,6 +62,9 @@ module Dyndnsd
|
|
51
62
|
end
|
52
63
|
end
|
53
64
|
|
65
|
+
# @param username [String]
|
66
|
+
# @param password [String]
|
67
|
+
# @return [Boolean]
|
54
68
|
def authorized?(username, password)
|
55
69
|
Helper.span('check_authorized') do |span|
|
56
70
|
span.set_tag('dyndnsd.user', username)
|
@@ -64,6 +78,8 @@ module Dyndnsd
|
|
64
78
|
end
|
65
79
|
end
|
66
80
|
|
81
|
+
# @param env [Hash{String => String}]
|
82
|
+
# @return [Array{Integer,Hash{String => String},Array{String}}]
|
67
83
|
def call(env)
|
68
84
|
return [422, {'X-DynDNS-Response' => 'method_forbidden'}, []] if env['REQUEST_METHOD'] != 'GET'
|
69
85
|
return [422, {'X-DynDNS-Response' => 'not_found'}, []] if env['PATH_INFO'] != '/nic/update'
|
@@ -71,6 +87,7 @@ module Dyndnsd
|
|
71
87
|
handle_dyndns_request(env)
|
72
88
|
end
|
73
89
|
|
90
|
+
# @return [void]
|
74
91
|
def self.run!
|
75
92
|
if ARGV.length != 1
|
76
93
|
puts 'Usage: dyndnsd config_file'
|
@@ -109,6 +126,8 @@ module Dyndnsd
|
|
109
126
|
|
110
127
|
private
|
111
128
|
|
129
|
+
# @param params [Hash{String => String}]
|
130
|
+
# @return [Array{String}]
|
112
131
|
def extract_v4_and_v6_address(params)
|
113
132
|
return [] if !(params['myip'])
|
114
133
|
begin
|
@@ -120,6 +139,9 @@ module Dyndnsd
|
|
120
139
|
end
|
121
140
|
end
|
122
141
|
|
142
|
+
# @param env [Hash{String => String}]
|
143
|
+
# @param params [Hash{String => String}]
|
144
|
+
# @return [Array{String}]
|
123
145
|
def extract_myips(env, params)
|
124
146
|
# require presence of myip parameter as valid IPAddr (v4) and valid myip6
|
125
147
|
return extract_v4_and_v6_address(params) if params.key?('myip6')
|
@@ -134,6 +156,9 @@ module Dyndnsd
|
|
134
156
|
[env['REMOTE_ADDR']]
|
135
157
|
end
|
136
158
|
|
159
|
+
# @param hostnames [String]
|
160
|
+
# @param myips [Array{String}]
|
161
|
+
# @return [Array{Symbol}]
|
137
162
|
def process_changes(hostnames, myips)
|
138
163
|
changes = []
|
139
164
|
Helper.span('process_changes') do |span|
|
@@ -158,6 +183,7 @@ module Dyndnsd
|
|
158
183
|
changes
|
159
184
|
end
|
160
185
|
|
186
|
+
# @return [void]
|
161
187
|
def update_db
|
162
188
|
@db['serial'] += 1
|
163
189
|
Dyndnsd.logger.info "Committing update ##{@db['serial']}"
|
@@ -166,6 +192,8 @@ module Dyndnsd
|
|
166
192
|
Metriks.meter('updates.committed').mark
|
167
193
|
end
|
168
194
|
|
195
|
+
# @param env [Hash{String => String}]
|
196
|
+
# @return [Array{Integer,Hash{String => String},Array{String}}]
|
169
197
|
def handle_dyndns_request(env)
|
170
198
|
params = Rack::Utils.parse_query(env['QUERY_STRING'])
|
171
199
|
|
@@ -204,6 +232,8 @@ module Dyndnsd
|
|
204
232
|
|
205
233
|
# SETUP
|
206
234
|
|
235
|
+
# @param config [Hash{String => Object}]
|
236
|
+
# @return [void]
|
207
237
|
private_class_method def self.setup_logger(config)
|
208
238
|
if config['logfile']
|
209
239
|
Dyndnsd.logger = Logger.new(config['logfile'])
|
@@ -215,6 +245,7 @@ module Dyndnsd
|
|
215
245
|
Dyndnsd.logger.formatter = LogFormatter.new
|
216
246
|
end
|
217
247
|
|
248
|
+
# @return [void]
|
218
249
|
private_class_method def self.setup_traps
|
219
250
|
Signal.trap('INT') do
|
220
251
|
Dyndnsd.logger.info 'Quitting...'
|
@@ -226,6 +257,8 @@ module Dyndnsd
|
|
226
257
|
end
|
227
258
|
end
|
228
259
|
|
260
|
+
# @param config [Hash{String => Object}]
|
261
|
+
# @return [void]
|
229
262
|
private_class_method def self.setup_monitoring(config)
|
230
263
|
# configure metriks
|
231
264
|
if config['graphite']
|
@@ -253,6 +286,8 @@ module Dyndnsd
|
|
253
286
|
end
|
254
287
|
end
|
255
288
|
|
289
|
+
# @param config [Hash{String => Object}]
|
290
|
+
# @return [void]
|
256
291
|
private_class_method def self.setup_tracing(config)
|
257
292
|
# configure OpenTracing
|
258
293
|
if config.dig('tracing', 'jaeger')
|
@@ -267,10 +302,12 @@ module Dyndnsd
|
|
267
302
|
end
|
268
303
|
end
|
269
304
|
|
305
|
+
# @param config [Hash{String => Object}]
|
306
|
+
# @return [void]
|
270
307
|
private_class_method def self.setup_rack(config)
|
271
308
|
# configure daemon
|
272
309
|
db = Database.new(config['db'])
|
273
|
-
updater = Updater::CommandWithBindZone.new(config['domain'], config
|
310
|
+
updater = Updater::CommandWithBindZone.new(config['domain'], config.dig('updater', 'params')) if config.dig('updater', 'name') == 'command_with_bind_zone'
|
274
311
|
daemon = Daemon.new(config, db, updater)
|
275
312
|
|
276
313
|
# configure rack
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dyndnsd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Nicolai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.
|
75
|
+
version: 0.9.0
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.
|
82
|
+
version: 0.9.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: jaeger-client
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,16 +156,30 @@ dependencies:
|
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: 0.
|
159
|
+
version: 0.80.0
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: 0.
|
166
|
+
version: 0.80.0
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: bundler-audit
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 0.6.0
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: 0.6.0
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: solargraph
|
169
183
|
requirement: !ruby/object:Gem::Requirement
|
170
184
|
requirements:
|
171
185
|
- - ">="
|
@@ -188,7 +202,7 @@ extra_rdoc_files: []
|
|
188
202
|
files:
|
189
203
|
- ".gitignore"
|
190
204
|
- ".rubocop.yml"
|
191
|
-
- ".
|
205
|
+
- ".solargraph.yml"
|
192
206
|
- ".travis.yml"
|
193
207
|
- CHANGELOG.md
|
194
208
|
- Gemfile
|
@@ -230,8 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
230
244
|
- !ruby/object:Gem::Version
|
231
245
|
version: '0'
|
232
246
|
requirements: []
|
233
|
-
|
234
|
-
rubygems_version: 2.7.7
|
247
|
+
rubygems_version: 3.0.6
|
235
248
|
signing_key:
|
236
249
|
specification_version: 4
|
237
250
|
summary: dyndnsd.rb
|
data/.rubocop_todo.yml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
# This configuration was generated by
|
2
|
-
# `rubocop --auto-gen-config`
|
3
|
-
# on 2018-02-23 12:54:10 +0100 using RuboCop version 0.52.1.
|
4
|
-
# The point is for the user to remove these configuration records
|
5
|
-
# one by one as the offenses are removed from the code base.
|
6
|
-
# Note that changes in the inspected code, or installation of new
|
7
|
-
# versions of RuboCop, may require this file to be generated again.
|