dns-update 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d1f080a6f86d312152c8e79dafc6bcbc96e440c5
4
+ data.tar.gz: 3797be0c1130f65936a08b21c4fc74c16056d0f1
5
+ SHA512:
6
+ metadata.gz: 4cc00c0a655bb70bf42ea28952261c801aec7282596c9ea9f032144bbdb1ed5664ce4f8e5eda7764135542b110123a5e796ee2db20aba2b1a319e61ccf9833c9
7
+ data.tar.gz: 3b7639c28985deaa87fffbb5f905b2daaa8171a21af48b223fb948a17f9709a1ee3e2a6544c4a19b729d0bb4fc5d8b29500d3dd5a36d0adadfefffdc38795914
@@ -0,0 +1,50 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ # Gemfile.lock
46
+ .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
@@ -0,0 +1,3 @@
1
+ ---
2
+ Style/FrozenStringLiteralComment:
3
+ Enabled: false
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gem 'dnsruby', '~>1.59'
@@ -0,0 +1,13 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ dnsruby (1.59.3)
5
+
6
+ PLATFORMS
7
+ ruby
8
+
9
+ DEPENDENCIES
10
+ dnsruby (~> 1.59)
11
+
12
+ BUNDLED WITH
13
+ 1.11.2
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016 Aaron Brady
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ # dns-update
2
+ Ruby Dynamic DNS Updater
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env ruby
2
+ require 'dnsruby'
3
+ require 'net/http'
4
+ require 'json'
5
+ require 'base64'
6
+ require 'optparse'
7
+
8
+ options = {
9
+ url: 'http://jsonip.com/',
10
+ key_name: 'keyname',
11
+ key: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=',
12
+ zone: 'insm.cf',
13
+ record: 'home.insm.cf',
14
+ nameserver: 'rho.insom.me.uk',
15
+ ttl: 300
16
+ }
17
+
18
+ OptionParser.new do |opts|
19
+ opts.banner = "Usage: #{$PROGRAM_NAME} [options]"
20
+
21
+ opts.on('-u', '--url URL', 'JSON IP URL') do |v|
22
+ options[:url] = v
23
+ end
24
+ opts.on('-e', '--key-name KEY-NAME', 'Name of the TSIG key') do |v|
25
+ options[:key_name] = v
26
+ end
27
+ opts.on('-k', '--key KEY', 'Base64 encoded TSIG key') do |v|
28
+ options[:key] = v
29
+ end
30
+ opts.on('-z', '--zone ZONE', 'DNS Zone to update') do |v|
31
+ options[:zone] = v
32
+ end
33
+ opts.on('-r', '--record RECORD', 'DNS Record to update') do |v|
34
+ options[:record] = v
35
+ end
36
+ opts.on('-n', '--nameserver NAMESERVER', 'Nameserver to update') do |v|
37
+ options[:nameserver] = v
38
+ end
39
+ opts.on('-t', '--ttl TTL', Integer, 'TTL of newly updated record') do |v|
40
+ options[:ttl] = v
41
+ end
42
+ end.parse!
43
+
44
+ decoded_key = Base64.decode64(options[:key])
45
+
46
+ uri = URI(options[:url])
47
+ response = Net::HTTP.get(uri)
48
+ j = JSON.parse(response)
49
+
50
+ update = Dnsruby::Update.new(options[:zone])
51
+ update.delete("#{options[:record]}.", 'A')
52
+ update.add("#{options[:record]}.", 'A', options[:ttl], j['ip'])
53
+
54
+ res = Dnsruby::Resolver.new(nameserver: options[:nameserver])
55
+
56
+ tsig = Dnsruby::RR::TSIG.new
57
+ tsig.algorithm = \
58
+ case decoded_key.length
59
+ when 32
60
+ Dnsruby::RR::TSIG::HMAC_SHA256
61
+ when 20
62
+ Dnsruby::RR::TSIG::HMAC_SHA1
63
+ else
64
+ Dnsruby::RR::TSIG::HMAC_MD5
65
+ end
66
+ tsig.key = options[:key]
67
+ tsig.name = options[:key_name]
68
+ res.tsig = tsig
69
+
70
+ begin
71
+ res.send_message(update)
72
+ rescue Dnsruby::TsigError
73
+ STDERR.puts 'Your TSIG secret was rejected by the server'
74
+ end
@@ -0,0 +1,21 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = 'dns-update'
3
+ spec.version = '0.0.1'
4
+ spec.authors = ['Aaron Brady']
5
+ spec.email = ['aaron@insom.me.uk']
6
+
7
+ spec.summary = 'Update BIND with your new IP'
8
+ spec.description = "Speaks nsupdate's protocol, queries jsonip.com"
9
+ spec.homepage = 'https://github.com/insom/dns-update'
10
+ spec.license = 'MIT'
11
+
12
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
13
+ f.match(%r{^(test|spec|features)/})
14
+ end
15
+ spec.bindir = 'bin'
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+
18
+ spec.add_dependency 'dnsruby', '~> 1.59'
19
+
20
+ spec.add_development_dependency 'bundler', '~> 1.12'
21
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dns-update
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Aaron Brady
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-09-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: dnsruby
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.59'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.59'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.12'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.12'
41
+ description: Speaks nsupdate's protocol, queries jsonip.com
42
+ email:
43
+ - aaron@insom.me.uk
44
+ executables:
45
+ - dns-update
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - ".rubocop.yml"
51
+ - Gemfile
52
+ - Gemfile.lock
53
+ - LICENSE
54
+ - README.md
55
+ - bin/dns-update
56
+ - dns-update.gemspec
57
+ homepage: https://github.com/insom/dns-update
58
+ licenses:
59
+ - MIT
60
+ metadata: {}
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 2.5.1
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: Update BIND with your new IP
81
+ test_files: []