DNSUpdater 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +4 -0
- data/.rubocop.yml +56 -0
- data/.travis.yml +7 -0
- data/.yardopts +6 -0
- data/CHANGELOG.md +14 -0
- data/DNSUpdater.gemspec +46 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +77 -0
- data/README.md +138 -0
- data/Rakefile +12 -0
- data/UNLICENSE +24 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/config.ru +5 -0
- data/config_example.yaml +23 -0
- data/exe/updateDNS +6 -0
- data/lib/dnsupdater.rb +92 -0
- data/lib/dnsupdater/cli.rb +96 -0
- data/lib/dnsupdater/config.rb +64 -0
- data/lib/dnsupdater/error.rb +7 -0
- data/lib/dnsupdater/updaters.rb +30 -0
- data/lib/dnsupdater/updaters/all.rb +5 -0
- data/lib/dnsupdater/updaters/http.rb +227 -0
- data/lib/dnsupdater/updaters/powerdns.rb +108 -0
- data/lib/dnsupdater/updaters/ssh.rb +127 -0
- data/lib/dnsupdater/updaters/updater.rb +78 -0
- data/lib/dnsupdater/utils.rb +20 -0
- data/lib/dnsupdater/version.rb +6 -0
- data/lib/dnsupdater/web.rb +47 -0
- data/service/dnsupdater.service +10 -0
- data/service/dnsupdater.timer +10 -0
- metadata +276 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1f825b3799de70e518a4216e6962814d8dfe9ef3e834f93d251fddaa269e4974
|
4
|
+
data.tar.gz: 909d0c529ea9fb6b974969e4cde18a39a97ad685fce54e1156e619afc9fb3479
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f30c522ac33ee2a56dcff7244e351a108f8de42847c55e2ca6661812f8d834f3a358215162e69f479c6a8bc306c5d06504e4b2af08304ca1fb7a5a573b027c64
|
7
|
+
data.tar.gz: 4da0b59cbb3c4ebbb8feddb9f7f884e1a386ce425268b93de1688a4c21d53374c2637131380d203511d53c0b24f5792b0c3053f701c88f0c56f2537a93296ec0
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
|
2
|
+
AllCops:
|
3
|
+
TargetRubyVersion: 2.6
|
4
|
+
|
5
|
+
Layout/IndentationWidth:
|
6
|
+
Width: 4
|
7
|
+
|
8
|
+
Layout/EndOfLine:
|
9
|
+
EnforcedStyle: lf
|
10
|
+
|
11
|
+
Layout/LineLength:
|
12
|
+
Enabled: false
|
13
|
+
|
14
|
+
Lint/UnusedMethodArgument:
|
15
|
+
Enabled: false
|
16
|
+
|
17
|
+
Naming/MethodName:
|
18
|
+
EnforcedStyle: camelCase
|
19
|
+
|
20
|
+
Naming/VariableName:
|
21
|
+
Enabled: false
|
22
|
+
EnforcedStyle: camelCase
|
23
|
+
|
24
|
+
Naming/BlockParameterName:
|
25
|
+
Enabled: false
|
26
|
+
|
27
|
+
Naming/MethodParameterName:
|
28
|
+
Enabled: false
|
29
|
+
AllowedNames:
|
30
|
+
- a
|
31
|
+
- b
|
32
|
+
|
33
|
+
Metrics/AbcSize:
|
34
|
+
Max: 35
|
35
|
+
|
36
|
+
Metrics/MethodLength:
|
37
|
+
Max: 25
|
38
|
+
|
39
|
+
Metrics/ClassLength:
|
40
|
+
Max: 200
|
41
|
+
|
42
|
+
Metrics/CyclomaticComplexity:
|
43
|
+
Max: 10
|
44
|
+
|
45
|
+
Style/ClassVars:
|
46
|
+
Enabled: false
|
47
|
+
|
48
|
+
Style/GlobalVars:
|
49
|
+
AllowedVariables:
|
50
|
+
- $spec
|
51
|
+
|
52
|
+
Metrics/BlockLength:
|
53
|
+
Max: 35
|
54
|
+
Exclude:
|
55
|
+
- spec/*_spec.rb
|
56
|
+
- spec/updaters/*_spec.rb
|
data/.travis.yml
ADDED
data/.yardopts
ADDED
data/CHANGELOG.md
ADDED
data/DNSUpdater.gemspec
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'dnsupdater/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'DNSUpdater'
|
9
|
+
spec.version = DNSUpdater::VERSION
|
10
|
+
spec.authors = ['Dāvis']
|
11
|
+
spec.email = ['davispuh@gmail.com']
|
12
|
+
|
13
|
+
spec.summary = 'An application to dynamically and remotely update DNS.'
|
14
|
+
spec.description = 'Using this application you can configure local or remote (over SSH or HTTP) DNS such as PowerDNS.'
|
15
|
+
spec.homepage = 'https://github.com/davispuh/DNSUpdater'
|
16
|
+
spec.license = 'UNLICENSE'
|
17
|
+
|
18
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
19
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
20
|
+
spec.metadata['changelog_uri'] = spec.homepage + '/blob/master/CHANGELOG.md'
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
25
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
end
|
27
|
+
spec.bindir = 'exe'
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ['lib']
|
30
|
+
|
31
|
+
spec.add_dependency 'addressable'
|
32
|
+
spec.add_dependency 'idn-ruby'
|
33
|
+
spec.add_dependency 'pdns_api'
|
34
|
+
spec.add_dependency 'public_suffix'
|
35
|
+
spec.add_dependency 'puma'
|
36
|
+
spec.add_dependency 'rack'
|
37
|
+
|
38
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
39
|
+
spec.add_development_dependency 'irb'
|
40
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
41
|
+
spec.add_development_dependency 'redcarpet'
|
42
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
43
|
+
spec.add_development_dependency 'simplecov'
|
44
|
+
spec.add_development_dependency 'webmock', '>= 3.7'
|
45
|
+
spec.add_development_dependency 'yard'
|
46
|
+
end
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
DNSUpdater (1.0.0)
|
5
|
+
addressable
|
6
|
+
idn-ruby
|
7
|
+
pdns_api
|
8
|
+
public_suffix
|
9
|
+
puma
|
10
|
+
rack
|
11
|
+
|
12
|
+
GEM
|
13
|
+
remote: https://rubygems.org/
|
14
|
+
specs:
|
15
|
+
addressable (2.7.0)
|
16
|
+
public_suffix (>= 2.0.2, < 5.0)
|
17
|
+
crack (0.4.3)
|
18
|
+
safe_yaml (~> 1.0.0)
|
19
|
+
diff-lcs (1.3)
|
20
|
+
docile (1.3.2)
|
21
|
+
hashdiff (1.0.0)
|
22
|
+
idn-ruby (0.1.0)
|
23
|
+
io-console (0.5.3)
|
24
|
+
irb (1.2.1)
|
25
|
+
reline (>= 0.0.1)
|
26
|
+
json (2.3.0)
|
27
|
+
nio4r (2.5.2)
|
28
|
+
pdns_api (0.1.3)
|
29
|
+
public_suffix (4.0.2)
|
30
|
+
puma (4.3.1)
|
31
|
+
nio4r (~> 2.0)
|
32
|
+
rack (2.0.8)
|
33
|
+
rake (10.5.0)
|
34
|
+
redcarpet (3.5.0)
|
35
|
+
reline (0.1.2)
|
36
|
+
io-console (~> 0.5)
|
37
|
+
rspec (3.9.0)
|
38
|
+
rspec-core (~> 3.9.0)
|
39
|
+
rspec-expectations (~> 3.9.0)
|
40
|
+
rspec-mocks (~> 3.9.0)
|
41
|
+
rspec-core (3.9.0)
|
42
|
+
rspec-support (~> 3.9.0)
|
43
|
+
rspec-expectations (3.9.0)
|
44
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
45
|
+
rspec-support (~> 3.9.0)
|
46
|
+
rspec-mocks (3.9.0)
|
47
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
48
|
+
rspec-support (~> 3.9.0)
|
49
|
+
rspec-support (3.9.0)
|
50
|
+
safe_yaml (1.0.5)
|
51
|
+
simplecov (0.17.1)
|
52
|
+
docile (~> 1.1)
|
53
|
+
json (>= 1.8, < 3)
|
54
|
+
simplecov-html (~> 0.10.0)
|
55
|
+
simplecov-html (0.10.2)
|
56
|
+
webmock (3.7.6)
|
57
|
+
addressable (>= 2.3.6)
|
58
|
+
crack (>= 0.3.2)
|
59
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
60
|
+
yard (0.9.20)
|
61
|
+
|
62
|
+
PLATFORMS
|
63
|
+
ruby
|
64
|
+
|
65
|
+
DEPENDENCIES
|
66
|
+
DNSUpdater!
|
67
|
+
bundler (~> 2.0)
|
68
|
+
irb
|
69
|
+
rake (~> 10.0)
|
70
|
+
redcarpet
|
71
|
+
rspec (~> 3.0)
|
72
|
+
simplecov
|
73
|
+
webmock (>= 3.7)
|
74
|
+
yard
|
75
|
+
|
76
|
+
BUNDLED WITH
|
77
|
+
2.1.2
|
data/README.md
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
# DNSUpdater - Dynamic DNS (DDNS)
|
2
|
+
|
3
|
+
Using this application you can update DNS records on local or remote (over SSH or HTTP) DNS server (eg. PowerDNS).
|
4
|
+
|
5
|
+
For example if you have dynamic IP you can use this application to automatically update DNS record with your external IP.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
First you need to have Ruby and RubyGems.
|
10
|
+
Then you can install it with:
|
11
|
+
|
12
|
+
```sh
|
13
|
+
$ gem install DNSUpdater
|
14
|
+
```
|
15
|
+
|
16
|
+
### Install Systemd service files
|
17
|
+
|
18
|
+
```sh
|
19
|
+
$ cp service/dnsupdater.{service,timer} /etc/systemd/system/
|
20
|
+
$ systemctl enable dnsupdater.timer
|
21
|
+
```
|
22
|
+
|
23
|
+
Note that you'll need to edit `/etc/systemd/system/dnsupdater.service` to set target domain.
|
24
|
+
|
25
|
+
### Configure
|
26
|
+
|
27
|
+
Create `/etc/dnsupdater.yaml` with your settings, take a look at [config_example.yaml](config_example.yaml).
|
28
|
+
|
29
|
+
By default configuration file will be looked into current directory as `config.yaml` or in `/etc/dnsupdater.yaml`.
|
30
|
+
But you can specify any config path with `-c` flag.
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
```sh
|
35
|
+
$ updateDNS -h
|
36
|
+
Usage: updateDNS [options] <target>
|
37
|
+
-c, --config config.yaml Path to config file
|
38
|
+
-t, --target=PROTOCOL Target protocol (useful for SSH)
|
39
|
+
-s, --serve Serve/handle HTTP
|
40
|
+
-h, --help Show this message
|
41
|
+
|
42
|
+
Supported targets are: http, https, powerdns, ssh
|
43
|
+
Target examples:
|
44
|
+
* default:///example.com/10.0.0.1
|
45
|
+
* ssh://dns.example.com:123/example.org/client
|
46
|
+
* http://example.org/dns.example.com/127.0.0.1,192.168.1.1
|
47
|
+
```
|
48
|
+
|
49
|
+
### Update DNS record on locally installed PowerDNS
|
50
|
+
|
51
|
+
`$ updateDNS powerdns:///domain.example.com/192.168.1.1`
|
52
|
+
|
53
|
+
Note that you'll need to set PowerDNS HTTP API key in config.
|
54
|
+
|
55
|
+
### Update DNS record on remote PowerDNS over SSH with current external IP
|
56
|
+
|
57
|
+
`$ updateDNS ssh://ssh.example.org/domain.example.com/client`
|
58
|
+
|
59
|
+
`client` as IP means that DNS record will be updated with your external IP (client IP from target DNS server point).
|
60
|
+
|
61
|
+
SSH settings can also be configured in `~/.ssh/config` which will be respected.
|
62
|
+
|
63
|
+
### HTTP server mode
|
64
|
+
|
65
|
+
DNSUpdater can also work as HTTP server and update DNS records from clients.
|
66
|
+
|
67
|
+
`$ updateDNS --serve http://192.168.1.2/`
|
68
|
+
|
69
|
+
For authentication you'll need to set `SharedSecret` in config.
|
70
|
+
Also I recommend placing it behind Nginx.
|
71
|
+
|
72
|
+
Then clients can do
|
73
|
+
```
|
74
|
+
$ updateDNS http://192.168.1.2/domain.example.com/client
|
75
|
+
```
|
76
|
+
|
77
|
+
PS. It also accepts DynDNS format: `/nic/update?hostname=yourhostname&myip=ipaddress`
|
78
|
+
|
79
|
+
### Update DNS record on firewalled remote PowerDNS over SSH with HTTP
|
80
|
+
|
81
|
+
Suppose you have 3 machines:
|
82
|
+
|
83
|
+
`A` - internal firewalled PowerDNS server which isn't accessible publicly.
|
84
|
+
|
85
|
+
`B` - publicly accessible HTTP server.
|
86
|
+
|
87
|
+
`C` - client who's external IP you want to set.
|
88
|
+
|
89
|
+
|
90
|
+
On `B` you would run `updateDNS -s` in HTTP server mode configured that it updates PowerDNS on `A` over SSH.
|
91
|
+
|
92
|
+
On `C` you would run `updateDNS https://B/mydomain.example.com/client`
|
93
|
+
|
94
|
+
## Updaters/Providers
|
95
|
+
|
96
|
+
Basically currently there's support only for PowerDNS and don't have BIND support,
|
97
|
+
but it should be pretty easy to add support for others so just send a PR :)
|
98
|
+
|
99
|
+
## Documentation
|
100
|
+
|
101
|
+
YARD with markdown is used for documentation (`redcarpet` required)
|
102
|
+
|
103
|
+
## Specs
|
104
|
+
|
105
|
+
RSpec and simplecov are required, to run tests just `rake spec`
|
106
|
+
code coverage will also be generated
|
107
|
+
|
108
|
+
## Code status
|
109
|
+
[![Gem Version](https://badge.fury.io/rb/DNSUpdater.png)](http://badge.fury.io/rb/DNSUpdater)
|
110
|
+
[![Build Status](https://travis-ci.org/davispuh/DNSUpdater.png?branch=master)](https://travis-ci.org/davispuh/DNSUpdater)
|
111
|
+
[![Coverage Status](https://coveralls.io/repos/davispuh/DNSUpdater/badge.png?branch=master)](https://coveralls.io/r/davispuh/DNSUpdater?branch=master)
|
112
|
+
|
113
|
+
## Unlicense
|
114
|
+
|
115
|
+
![Copyright-Free](http://unlicense.org/pd-icon.png)
|
116
|
+
|
117
|
+
All text, documentation, code and files in this repository are in public domain (including this text, README).
|
118
|
+
It means you can copy, modify, distribute and include in your own work/code, even for commercial purposes, all without asking permission.
|
119
|
+
|
120
|
+
[About Unlicense](http://unlicense.org/)
|
121
|
+
|
122
|
+
## Contributing
|
123
|
+
|
124
|
+
Feel free to improve as you see.
|
125
|
+
|
126
|
+
1. Fork it
|
127
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
128
|
+
3. Export `.yaml` data files to binary `.dat` with `rake export`
|
129
|
+
4. Commit your changes (`git commit -am 'Add some feature'`)
|
130
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
131
|
+
6. Create new Pull Request
|
132
|
+
|
133
|
+
|
134
|
+
**Warning**: By sending pull request to this repository you dedicate any and all copyright interest in pull request (code files and all other) to the public domain. (files will be in public domain even if pull request doesn't get merged)
|
135
|
+
|
136
|
+
Also before sending pull request you acknowledge that you own all copyrights or have authorization to dedicate them to public domain.
|
137
|
+
|
138
|
+
If you don't want to dedicate code to public domain or if you're not allowed to (eg. you don't own required copyrights) then DON'T send pull request.
|
data/Rakefile
ADDED
data/UNLICENSE
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
This is free and unencumbered software released into the public domain.
|
2
|
+
|
3
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
4
|
+
distribute this software, either in source code form or as a compiled
|
5
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
6
|
+
means.
|
7
|
+
|
8
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
9
|
+
of this software dedicate any and all copyright interest in the
|
10
|
+
software to the public domain. We make this dedication for the benefit
|
11
|
+
of the public at large and to the detriment of our heirs and
|
12
|
+
successors. We intend this dedication to be an overt act of
|
13
|
+
relinquishment in perpetuity of all present and future rights to this
|
14
|
+
software under copyright law.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
20
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
21
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
For more information, please refer to <http://unlicense.org/>
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require_relative '../lib/dnsupdater'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require 'pry'
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|