dyndnsd 2.1.1 → 3.1.0.rc1

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.
data/.gitignore DELETED
@@ -1,4 +0,0 @@
1
- .DS_Store
2
- *.lock
3
- pkg/*
4
- .yardoc
@@ -1,87 +0,0 @@
1
- AllCops:
2
- TargetRubyVersion: '2.3'
3
-
4
- Gemspec/OrderedDependencies:
5
- Enabled: false
6
-
7
- Layout/EmptyLineAfterGuardClause:
8
- Enabled: false
9
-
10
- # allows nicer usage of private_class_method
11
- Layout/EmptyLinesAroundArguments:
12
- Enabled: false
13
-
14
- Layout/HashAlignment:
15
- Enabled: false
16
-
17
- Layout/LeadingEmptyLines:
18
- Enabled: false
19
-
20
- Layout/LineLength:
21
- Max: 200
22
-
23
- Layout/SpaceInsideHashLiteralBraces:
24
- Enabled: false
25
-
26
- Metrics/AbcSize:
27
- Enabled: false
28
-
29
- Metrics/BlockLength:
30
- Enabled: false
31
-
32
- Metrics/ClassLength:
33
- Enabled: false
34
-
35
- Metrics/CyclomaticComplexity:
36
- Enabled: false
37
-
38
- Metrics/MethodLength:
39
- Enabled: false
40
-
41
- Metrics/PerceivedComplexity:
42
- Enabled: false
43
-
44
- Naming/MethodParameterName:
45
- Enabled: false
46
-
47
- Naming/MemoizedInstanceVariableName:
48
- Enabled: false
49
-
50
- Style/ConditionalAssignment:
51
- Enabled: false
52
-
53
- Style/Documentation:
54
- Enabled: false
55
-
56
- Style/FormatStringToken:
57
- Enabled: false
58
-
59
- Style/FrozenStringLiteralComment:
60
- Enabled: false
61
-
62
- Style/GuardClause:
63
- Enabled: false
64
-
65
- Style/HashEachMethods:
66
- Enabled: true
67
-
68
- Style/HashTransformKeys:
69
- Enabled: true
70
-
71
- Style/HashTransformValues:
72
- Enabled: true
73
-
74
- Style/IdenticalConditionalBranches:
75
- Enabled: false
76
-
77
- Style/InverseMethods:
78
- Enabled: false
79
-
80
- Style/NegatedIf:
81
- Enabled: false
82
-
83
- Style/RescueModifier:
84
- Enabled: false
85
-
86
- Style/SymbolArray:
87
- Enabled: false
@@ -1,16 +0,0 @@
1
- ---
2
- include:
3
- - "**/*.rb"
4
- - "bin/dyndnsd"
5
- exclude:
6
- - spec/**/*
7
- - test/**/*
8
- - vendor/**/*
9
- - ".bundle/**/*"
10
- require: []
11
- domains: []
12
- reporters:
13
- - rubocop
14
- - require_not_found
15
- require_paths: []
16
- max_files: 5000
@@ -1,12 +0,0 @@
1
- ---
2
- os: linux
3
- language: ruby
4
- rvm:
5
- - 2.7
6
- - 2.6
7
- - 2.5
8
- - 2.4
9
- - 2.3
10
-
11
- script:
12
- - bundle exec rake travis
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
data/Rakefile DELETED
@@ -1,22 +0,0 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
3
- require 'rubocop/rake_task'
4
- require 'bundler/audit/task'
5
-
6
- RSpec::Core::RakeTask.new(:spec)
7
- RuboCop::RakeTask.new
8
- Bundler::Audit::Task.new
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
-
20
- task default: [:rubocop, :spec, 'bundle:audit']
21
-
22
- task travis: [:default, :'solargraph:tc']
@@ -1,4 +0,0 @@
1
-
2
- require 'dyndnsd'
3
-
4
- Dyndnsd::Daemon.run!
@@ -1,37 +0,0 @@
1
-
2
- $LOAD_PATH.push File.expand_path('lib', __dir__)
3
-
4
- require 'dyndnsd/version'
5
-
6
- Gem::Specification.new do |s|
7
- s.name = 'dyndnsd'
8
- s.version = Dyndnsd::VERSION
9
- s.summary = 'dyndnsd.rb'
10
- s.description = 'A small, lightweight and extensible DynDNS server written with Ruby and Rack.'
11
- s.author = 'Christian Nicolai'
12
- s.email = 'chrnicolai@gmail.com'
13
- s.homepage = 'https://github.com/cmur2/dyndnsd'
14
- s.license = 'Apache-2.0'
15
-
16
- s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
- s.test_files = s.files.grep(%r{^(test|spec|features)/})
18
- s.require_paths = ['lib']
19
- s.executables = ['dyndnsd']
20
-
21
- s.required_ruby_version = '>= 2.3'
22
-
23
- s.add_runtime_dependency 'rack', '~> 2.0'
24
- s.add_runtime_dependency 'json'
25
- s.add_runtime_dependency 'metriks'
26
- s.add_runtime_dependency 'opentracing', '~> 0.5.0'
27
- s.add_runtime_dependency 'rack-tracer', '~> 0.9.0'
28
- s.add_runtime_dependency 'jaeger-client', '~> 0.10.0'
29
-
30
- s.add_development_dependency 'bundler'
31
- s.add_development_dependency 'rake'
32
- s.add_development_dependency 'rspec'
33
- s.add_development_dependency 'rack-test'
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'
37
- end
@@ -1,43 +0,0 @@
1
- #! /bin/sh
2
- ### BEGIN INIT INFO
3
- # Provides: dyndnsd
4
- # Required-Start: $remote_fs $syslog
5
- # Required-Stop: $remote_fs $syslog
6
- # Default-Start: 2 3 4 5
7
- # Default-Stop: 0 1 6
8
- # Short-Description: Handle dyndnsd.rb gem
9
- ### END INIT INFO
10
-
11
- # using the system ruby's gem binaries directory
12
- DAEMON="/var/lib/gems/1.8/bin/dyndnsd"
13
-
14
- CONFIG_FILE="/opt/dyndnsd/config.yaml"
15
-
16
- DAEMON_OPTS="$CONFIG_FILE"
17
-
18
- test -x $DAEMON || exit 0
19
-
20
- . /lib/lsb/init-functions
21
-
22
- case "$1" in
23
- start)
24
- log_daemon_msg "Starting dyndnsd.rb" "dyndnsd"
25
- start-stop-daemon --start --quiet --oknodo --make-pidfile --pidfile "/var/run/dyndnsd.pid" --background --exec $DAEMON -- $DAEMON_OPTS
26
- log_end_msg $?
27
- ;;
28
- stop)
29
- log_daemon_msg "Stopping dyndnsd.rb" "dyndnsd"
30
- start-stop-daemon --stop --quiet --oknodo --pidfile "/var/run/dyndnsd.pid"
31
- log_end_msg $?
32
- ;;
33
- restart|force-reload)
34
- log_daemon_msg "Restarting dyndnsd.rb" "dyndnsd"
35
- start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile "/var/run/dyndsd.pid"
36
- start-stop-daemon --start --quiet --oknodo --make-pidfile --pidfile "/var/run/dyndnsd.pid" --background --exec $DAEMON -- $DAEMON_OPTS
37
- log_end_msg $?
38
- ;;
39
- *)
40
- log_action_msg "Usage: $0 {start|stop|restart|force-reload}"
41
- exit 2
42
- ;;
43
- esac
@@ -1,240 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Dyndnsd::Daemon do
4
- include Rack::Test::Methods
5
-
6
- def app
7
- Dyndnsd.logger = Logger.new(STDOUT)
8
- Dyndnsd.logger.level = Logger::UNKNOWN
9
-
10
- config = {
11
- 'domain' => 'example.org',
12
- 'users' => {
13
- 'test' => {
14
- 'password' => 'secret',
15
- 'hosts' => ['foo.example.org', 'bar.example.org']
16
- }
17
- }
18
- }
19
- db = Dyndnsd::DummyDatabase.new({})
20
- updater = Dyndnsd::Updater::Dummy.new
21
- daemon = Dyndnsd::Daemon.new(config, db, updater)
22
-
23
- app = Rack::Auth::Basic.new(daemon, 'DynDNS', &daemon.method(:authorized?))
24
-
25
- app = Dyndnsd::Responder::DynDNSStyle.new(app)
26
-
27
- Rack::Tracer.new(app, trust_incoming_span: false)
28
- end
29
-
30
- it 'requires authentication' do
31
- get '/'
32
- expect(last_response.status).to eq(401)
33
- expect(last_response.body).to eq('badauth')
34
- end
35
-
36
- it 'requires configured correct credentials' do
37
- authorize 'test', 'wrongsecret'
38
- get '/'
39
- expect(last_response.status).to eq(401)
40
- expect(last_response.body).to eq('badauth')
41
- end
42
-
43
- it 'only supports GET requests' do
44
- authorize 'test', 'secret'
45
- post '/nic/update'
46
- expect(last_response.status).to eq(405)
47
- end
48
-
49
- it 'provides only the /nic/update URL' do
50
- authorize 'test', 'secret'
51
- get '/other/url'
52
- expect(last_response.status).to eq(404)
53
- end
54
-
55
- it 'requires the hostname query parameter' do
56
- authorize 'test', 'secret'
57
- get '/nic/update'
58
- expect(last_response).to be_ok
59
- expect(last_response.body).to eq('notfqdn')
60
- end
61
-
62
- it 'supports multiple hostnames in request' do
63
- authorize 'test', 'secret'
64
-
65
- get '/nic/update?hostname=foo.example.org,bar.example.org&myip=1.2.3.4'
66
- expect(last_response).to be_ok
67
- expect(last_response.body).to eq("good 1.2.3.4\ngood 1.2.3.4")
68
-
69
- get '/nic/update?hostname=foo.example.org,bar.example.org&myip=2001:db8::1'
70
- expect(last_response).to be_ok
71
- expect(last_response.body).to eq("good 2001:db8::1\ngood 2001:db8::1")
72
- end
73
-
74
- it 'rejects request if one hostname is invalid' do
75
- authorize 'test', 'secret'
76
-
77
- get '/nic/update?hostname=test'
78
- expect(last_response).to be_ok
79
- expect(last_response.body).to eq('notfqdn')
80
-
81
- get '/nic/update?hostname=test.example.com'
82
- expect(last_response).to be_ok
83
- expect(last_response.body).to eq('notfqdn')
84
-
85
- get '/nic/update?hostname=test.example.org.me'
86
- expect(last_response).to be_ok
87
- expect(last_response.body).to eq('notfqdn')
88
-
89
- get '/nic/update?hostname=foo.test.example.org'
90
- expect(last_response).to be_ok
91
- expect(last_response.body).to eq('notfqdn')
92
-
93
- get '/nic/update?hostname=in%20valid.example.org'
94
- expect(last_response).to be_ok
95
- expect(last_response.body).to eq('notfqdn')
96
-
97
- get '/nic/update?hostname=valid.example.org,in.valid.example.org'
98
- expect(last_response).to be_ok
99
- expect(last_response.body).to eq('notfqdn')
100
- end
101
-
102
- it 'rejects request if user does not own one hostname' do
103
- authorize 'test', 'secret'
104
-
105
- get '/nic/update?hostname=notmyhost.example.org'
106
- expect(last_response).to be_ok
107
- expect(last_response.body).to eq('nohost')
108
-
109
- get '/nic/update?hostname=foo.example.org,notmyhost.example.org'
110
- expect(last_response).to be_ok
111
- expect(last_response.body).to eq('nohost')
112
- end
113
-
114
- it 'updates a host on IP change' do
115
- authorize 'test', 'secret'
116
-
117
- get '/nic/update?hostname=foo.example.org&myip=1.2.3.4'
118
- expect(last_response).to be_ok
119
-
120
- get '/nic/update?hostname=foo.example.org&myip=1.2.3.40'
121
- expect(last_response).to be_ok
122
- expect(last_response.body).to eq('good 1.2.3.40')
123
-
124
- get '/nic/update?hostname=foo.example.org&myip=2001:db8::1'
125
- expect(last_response).to be_ok
126
-
127
- get '/nic/update?hostname=foo.example.org&myip=2001:db8::10'
128
- expect(last_response).to be_ok
129
- expect(last_response.body).to eq('good 2001:db8::10')
130
- end
131
-
132
- it 'returns IP no change' do
133
- authorize 'test', 'secret'
134
-
135
- get '/nic/update?hostname=foo.example.org&myip=1.2.3.4'
136
- expect(last_response).to be_ok
137
-
138
- get '/nic/update?hostname=foo.example.org&myip=1.2.3.4'
139
- expect(last_response).to be_ok
140
- expect(last_response.body).to eq('nochg 1.2.3.4')
141
-
142
- get '/nic/update?hostname=foo.example.org&myip=2001:db8::1'
143
- expect(last_response).to be_ok
144
-
145
- get '/nic/update?hostname=foo.example.org&myip=2001:db8::1'
146
- expect(last_response).to be_ok
147
- expect(last_response.body).to eq('nochg 2001:db8::1')
148
- end
149
-
150
- it 'outputs IP status per hostname' do
151
- authorize 'test', 'secret'
152
-
153
- get '/nic/update?hostname=foo.example.org&myip=1.2.3.4'
154
- expect(last_response).to be_ok
155
- expect(last_response.body).to eq('good 1.2.3.4')
156
-
157
- get '/nic/update?hostname=foo.example.org,bar.example.org&myip=1.2.3.4'
158
- expect(last_response).to be_ok
159
- expect(last_response.body).to eq("nochg 1.2.3.4\ngood 1.2.3.4")
160
-
161
- get '/nic/update?hostname=foo.example.org&myip=2001:db8::1'
162
- expect(last_response).to be_ok
163
- expect(last_response.body).to eq('good 2001:db8::1')
164
-
165
- get '/nic/update?hostname=foo.example.org,bar.example.org&myip=2001:db8::1'
166
- expect(last_response).to be_ok
167
- expect(last_response.body).to eq("nochg 2001:db8::1\ngood 2001:db8::1")
168
- end
169
-
170
- it 'offlines a host' do
171
- authorize 'test', 'secret'
172
-
173
- get '/nic/update?hostname=foo.example.org&myip=1.2.3.4'
174
- expect(last_response).to be_ok
175
- expect(last_response.body).to eq('good 1.2.3.4')
176
-
177
- get '/nic/update?hostname=foo.example.org&offline=YES'
178
- expect(last_response).to be_ok
179
- expect(last_response.body).to eq('good ')
180
-
181
- get '/nic/update?hostname=foo.example.org&offline=YES'
182
- expect(last_response).to be_ok
183
- expect(last_response.body).to eq('nochg ')
184
-
185
- get '/nic/update?hostname=foo.example.org&myip=1.2.3.4'
186
- expect(last_response).to be_ok
187
- expect(last_response.body).to eq('good 1.2.3.4')
188
-
189
- get '/nic/update?hostname=foo.example.org&myip=1.2.3.4&offline=YES'
190
- expect(last_response).to be_ok
191
- expect(last_response.body).to eq('good ')
192
-
193
- get '/nic/update?hostname=foo.example.org&myip=1.2.3.4&offline=YES'
194
- expect(last_response).to be_ok
195
- expect(last_response.body).to eq('nochg ')
196
- end
197
-
198
- it 'uses clients remote IP address if myip not specified' do
199
- authorize 'test', 'secret'
200
- get '/nic/update?hostname=foo.example.org'
201
- expect(last_response).to be_ok
202
- expect(last_response.body).to eq('good 127.0.0.1')
203
- end
204
-
205
- it 'uses clients remote IP address from X-Real-IP header if behind proxy' do
206
- authorize 'test', 'secret'
207
-
208
- get '/nic/update?hostname=foo.example.org', '', 'HTTP_X_REAL_IP' => '10.0.0.1'
209
- expect(last_response).to be_ok
210
- expect(last_response.body).to eq('good 10.0.0.1')
211
-
212
- get '/nic/update?hostname=foo.example.org', '', 'HTTP_X_REAL_IP' => '2001:db8::1'
213
- expect(last_response).to be_ok
214
- expect(last_response.body).to eq('good 2001:db8::1')
215
- end
216
-
217
- it 'supports an IPv4 and an IPv6 address in one request' do
218
- authorize 'test', 'secret'
219
-
220
- get '/nic/update?hostname=foo.example.org&myip=1.2.3.4&myip6=2001:db8::1'
221
- expect(last_response).to be_ok
222
- expect(last_response.body).to eq('good 1.2.3.4 2001:db8::1')
223
-
224
- get '/nic/update?hostname=foo.example.org&myip=BROKENIP&myip6=2001:db8::1'
225
- expect(last_response).to be_ok
226
- expect(last_response.body).to eq('nohost')
227
-
228
- get '/nic/update?hostname=foo.example.org&myip=1.2.3.4&myip6=BROKENIP'
229
- expect(last_response).to be_ok
230
- expect(last_response.body).to eq('nohost')
231
-
232
- get '/nic/update?hostname=foo.example.org&myip6=2001:db8::10'
233
- expect(last_response).to be_ok
234
- expect(last_response.body).to eq('nohost')
235
-
236
- get '/nic/update?hostname=foo.example.org&myip=1.2.3.40'
237
- expect(last_response).to be_ok
238
- expect(last_response.body).to eq('good 1.2.3.40')
239
- end
240
- end