cloudflare-dns-update 2.4.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d4a239d0b54697dda4f730ced2d6c8b50427ff8fb785e4faed3989a6e01fe23
4
- data.tar.gz: 575dd25d15ac7a5bfdda9769b7509d83dfce33faffa9d8c8f3986f75da681824
3
+ metadata.gz: 84fada8eb1262bb18ed4a1e7d0392f958abe2a311f9fcba6a1703d6cea946634
4
+ data.tar.gz: b51bd44936abe2811def5ddbc0d9afcc5c74e2c447d4c36d2185904e1f8365b3
5
5
  SHA512:
6
- metadata.gz: 52987d3da7c1c91471d011679b9537c499015a3a9ef9bdb2b6d9e1467e3241fcadb41714924ec62cb757af363860133b98f38288d8116870f2e0ae3b63aa1e34
7
- data.tar.gz: 4dbb0599360c063ebd27628663488249aadb380ff891e173a966a1fd183c50f6a75f11772e186b7bf12be55f5982974cc88ae09a5908969fdd20bf158d756835
6
+ metadata.gz: 1df9331da1630b9eacf84167a68b893dd2002496e70cb03e2d55d731deb91b1eeeea66441cbf2ac29adeb2853edd962d544715a9cfb4965cf79db48ad352bd87
7
+ data.tar.gz: a0d4cfadca21c79211029fd65731f54739c0ba45b45f587ed7b746cf3d8b8c5d8a5c98725656efcd62441968e21adab3e9b1966ba94dad48eeaf995c6733a00c
@@ -20,6 +20,13 @@
20
20
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
21
  # THE SOFTWARE.
22
22
 
23
- require 'cloudflare/dns/update/command'
23
+ require_relative '../lib/cloudflare/dns/update/command'
24
24
 
25
- Cloudflare::DNS::Update::Command.parse(ARGV).invoke
25
+ begin
26
+ Cloudflare::DNS::Update::Command.call
27
+ rescue Interrupt
28
+ # Ignore.
29
+ rescue => error
30
+ Async.logger.error(Falcon::Command) {error}
31
+ exit! 1
32
+ end
Binary file
@@ -30,8 +30,8 @@ require_relative 'version'
30
30
 
31
31
  module Cloudflare::DNS::Update
32
32
  module Command
33
- def self.parse(*args)
34
- Top.parse(*args)
33
+ def self.call(*arguments)
34
+ Top.call(*arguments)
35
35
  end
36
36
 
37
37
  # The top level utopia command.
@@ -41,19 +41,9 @@ module Cloudflare::DNS::Update
41
41
  options do
42
42
  option '-c/--configuration <path>', "Use the specified configuration file.", default: 'dns.conf'
43
43
  option '-f/--force', "Force push updates to cloudflare even if content hasn't changed.", default: false
44
- option '--verbose | --quiet', "Verbosity of output for debugging.", key: :logging
45
- option '-h/--help', "Print out help information."
46
44
  option '-v/--version', "Print out the application version."
47
45
  end
48
46
 
49
- def verbose?
50
- @options[:logging] == :verbose
51
- end
52
-
53
- def quiet?
54
- @options[:logging] == :quiet
55
- end
56
-
57
47
  def logger
58
48
  @logger ||= Async.logger
59
49
  end
@@ -70,16 +60,12 @@ module Cloudflare::DNS::Update
70
60
 
71
61
  def connect!
72
62
  configuration_store.transaction do |configuration|
73
- unless configuration[:key]
74
- prompt.puts "This configuration file appears to be new, we require some details."
75
- configuration[:key] = prompt.mask("Cloudflare Key:")
76
- configuration[:email] = prompt.ask("Cloudflare Email:")
63
+ unless configuration[:token]
64
+ prompt.puts "This configuration does not contain authorization token, we require some details."
65
+ configuration[:token] = prompt.mask("Cloudflare token:")
77
66
  end
78
67
 
79
- key = configuration[:key]
80
- email = configuration[:email]
81
-
82
- @connection = Cloudflare.connect(key: key, email: email)
68
+ @connection = Cloudflare.connect(token: configuration[:token])
83
69
  end
84
70
 
85
71
  return @connection unless block_given?
@@ -175,19 +161,13 @@ module Cloudflare::DNS::Update
175
161
  return content
176
162
  end
177
163
 
178
- def invoke(program_name: File.basename($0))
164
+ def call
179
165
  if @options[:version]
180
166
  puts VERSION
181
167
  elsif @options[:help]
182
- print_usage(program_name)
168
+ print_usage
183
169
  else
184
- if verbose?
185
- Async.logger.debug!
186
- elsif quiet?
187
- Async.logger.warn!
188
- end
189
-
190
- Async do
170
+ Sync do
191
171
  connect! do
192
172
  initialize_zone
193
173
  initialize_domains
@@ -195,7 +175,7 @@ module Cloudflare::DNS::Update
195
175
 
196
176
  update_domains
197
177
  end
198
- end.wait
178
+ end
199
179
  end
200
180
  end
201
181
  end
@@ -22,7 +22,7 @@
22
22
  module Cloudflare
23
23
  module DNS
24
24
  module Update
25
- VERSION = "2.4.1"
25
+ VERSION = "3.0.0"
26
26
  end
27
27
  end
28
28
  end
metadata CHANGED
@@ -1,57 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudflare-dns-update
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-09 00:00:00.000000000 Z
11
+ date: 2020-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: samovar
14
+ name: cloudflare
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.3'
19
+ version: '4.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.3'
26
+ version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: tty-prompt
28
+ name: samovar
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.16.0
33
+ version: '2.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.16.0
40
+ version: '2.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: cloudflare
42
+ name: tty-prompt
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '4.0'
47
+ version: '0.21'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '4.0'
54
+ version: '0.21'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: async-rspec
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: covered
70
+ name: bundler
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: bundler
84
+ name: covered
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -95,60 +95,50 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: rspec
98
+ name: rake
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
- version: '3.6'
103
+ version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "~>"
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: '3.6'
110
+ version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: rake
112
+ name: rspec
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '0'
117
+ version: '3.6'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '0'
125
- description: "\tProvides a client tool for updating Cloudflare records, with a specific\n\temphasis
126
- on updating IP addresses for domain records. This provides\n\tdyndns-like functionality.\n"
124
+ version: '3.6'
125
+ description:
127
126
  email:
128
- - samuel.williams@oriontransfer.co.nz
129
127
  executables:
130
128
  - cloudflare-dns-update
131
129
  extensions: []
132
130
  extra_rdoc_files: []
133
131
  files:
134
- - ".gitignore"
135
- - ".rspec"
136
- - ".travis.yml"
137
- - Gemfile
138
- - README.md
139
- - Rakefile
140
132
  - bin/cloudflare-dns-update
141
- - cloudflare-dns-update.gemspec
133
+ - lib/.DS_Store
142
134
  - lib/cloudflare/dns/update.rb
143
135
  - lib/cloudflare/dns/update/command.rb
144
136
  - lib/cloudflare/dns/update/version.rb
145
- - spec/cloudflare/dns/update/command_spec.rb
146
- - spec/spec_helper.rb
147
- homepage: ''
137
+ homepage:
148
138
  licenses:
149
139
  - MIT
150
140
  metadata: {}
151
- post_install_message:
141
+ post_install_message:
152
142
  rdoc_options: []
153
143
  require_paths:
154
144
  - lib
@@ -156,17 +146,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
156
146
  requirements:
157
147
  - - ">="
158
148
  - !ruby/object:Gem::Version
159
- version: '0'
149
+ version: '2.5'
160
150
  required_rubygems_version: !ruby/object:Gem::Requirement
161
151
  requirements:
162
152
  - - ">="
163
153
  - !ruby/object:Gem::Version
164
154
  version: '0'
165
155
  requirements: []
166
- rubygems_version: 3.0.2
167
- signing_key:
156
+ rubygems_version: 3.1.2
157
+ signing_key:
168
158
  specification_version: 4
169
159
  summary: A dyndns client for Cloudflare.
170
- test_files:
171
- - spec/cloudflare/dns/update/command_spec.rb
172
- - spec/spec_helper.rb
160
+ test_files: []
data/.gitignore DELETED
@@ -1,20 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
18
-
19
- .rspec_status
20
- spec/**/test.yaml
data/.rspec DELETED
@@ -1,4 +0,0 @@
1
- --format documentation
2
- --backtrace
3
- --warnings
4
- --require spec_helper
@@ -1,24 +0,0 @@
1
- language: ruby
2
- dist: xenial
3
- cache: bundler
4
-
5
- matrix:
6
- include:
7
- - rvm: 2.3
8
- - rvm: 2.4
9
- - rvm: 2.5
10
- - rvm: 2.6
11
- - rvm: 2.6
12
- env: COVERAGE=BriefSummary,Coveralls
13
- - rvm: jruby-head
14
- env: JRUBY_OPTS="--debug -X+O"
15
- - rvm: truffleruby
16
- - rvm: ruby-head
17
- allow_failures:
18
- - rvm: ruby-head
19
- - rvm: jruby-head
20
- - rvm: truffleruby
21
-
22
- env:
23
- global:
24
- secure: LU7mGKnIrWrnrdtq7Ug7HTxzqJoB+NbLHwT8dPmGf4GIfNosO4Jx+G4JLzUd/sCHzUR+XXrsMd7El8WkTVV28+nt6Cv2JvO4EJRIplnAL8Yauc0YSWRwA9nGYhcc2TJc5czbL0mZkJSOv4B+aWco0VWerJfgLYurIA05XrQFGGY=
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in utopia.gemspec
4
- gemspec
data/README.md DELETED
@@ -1,79 +0,0 @@
1
- # Cloudflare::DNS::Update
2
-
3
- This gem provides a simple executable tool for managing Cloudflare records to provide dynamic DNS like functionality. You need to add it to whatever `cron` system your host system uses.
4
-
5
- [![Build Status](https://secure.travis-ci.org/ioquatix/cloudflare-dns-update.svg)](http://travis-ci.org/ioquatix/cloudflare-dns-update)
6
- [![Coverage Status](https://coveralls.io/repos/socketry/cloudflare-dns-update/badge.svg)](https://coveralls.io/r/socketry/cloudflare-dns-update)
7
-
8
- [![Cloudflare DNS Update Introduction](http://img.youtube.com/vi/lQK6bWuQllM/maxresdefault.jpg)](https://www.youtube.com/watch?v=lQK6bWuQllM&feature=youtu.be&hd=1 "Cloudflare DNS Update Introduction")
9
-
10
- ## Installation
11
-
12
- Install it yourself as:
13
-
14
- $ gem install cloudflare-dns-update
15
-
16
- ## Usage
17
-
18
- Run the included `cloudflare-dns-update` tool and you will be walked through the configuration process. You might want to specify a specific configuration file, using the `--configuration /path/to/configuration.yml` option.
19
-
20
- ### Daily updates using CRON
21
-
22
- Simply set up configurations for each domain you wish to update, and add to `/etc/cron.daily/dyndns`, e.g.:
23
-
24
- #!/usr/bin/env sh
25
-
26
- cloudflare-dns-update --configuration /srv/dyndns/example.A.yml
27
- cloudflare-dns-update --configuration /srv/dyndns/example.AAAA.yml
28
-
29
- Note that in case you want to update more than one domains in a zone with the same IP address, you can have multiple domains in a configuration file. Follow instructions of the configuration process. Just to note, each domain would be updated with the same content. Having both IPv4 and IPv6 records in the same configuration file is not possible nor recommended. Please create separate configuration files.
30
-
31
- The configuration file would end up looking something like this:
32
-
33
- ---
34
- :key: b10_NOT_A_REAL_KEY_fe5
35
- :email: cloudflare-account@example.com
36
- :zone: example.com
37
- :content_command: curl ipinfo.io/ip
38
-
39
- ### IPv6 Support
40
-
41
- It is possible to update IPv6 when you have a dynamically allocated prefix. To get your current IPv6 address, the following command can be used:
42
-
43
- /sbin/ip -6 addr | awk -F '[ \t]+|/' '$3 == "::1" { next;} $3 ~ /^fe80::/ { next ; } /inet6/ {print $3}'
44
-
45
- ## Contributing
46
-
47
- 1. Fork it
48
- 2. Create your feature branch (`git checkout -b my-new-feature`)
49
- 3. Commit your changes (`git commit -am 'Add some feature'`)
50
- 4. Push to the branch (`git push origin my-new-feature`)
51
- 5. Create new Pull Request
52
-
53
- ## See Also
54
-
55
- - [cloudflare](https://github.com/ioquatix/cloudflare) – Provides access to Cloudflare.
56
-
57
- ## License
58
-
59
- Released under the MIT license.
60
-
61
- Copyright, 2017, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams).
62
-
63
- Permission is hereby granted, free of charge, to any person obtaining a copy
64
- of this software and associated documentation files (the "Software"), to deal
65
- in the Software without restriction, including without limitation the rights
66
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
67
- copies of the Software, and to permit persons to whom the Software is
68
- furnished to do so, subject to the following conditions:
69
-
70
- The above copyright notice and this permission notice shall be included in
71
- all copies or substantial portions of the Software.
72
-
73
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
74
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
75
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
76
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
77
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
78
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
79
- THE SOFTWARE.
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
@@ -1,35 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'cloudflare/dns/update/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "cloudflare-dns-update"
8
- spec.version = Cloudflare::DNS::Update::VERSION
9
- spec.authors = ["Samuel Williams"]
10
- spec.email = ["samuel.williams@oriontransfer.co.nz"]
11
- spec.description = <<-EOF
12
- Provides a client tool for updating Cloudflare records, with a specific
13
- emphasis on updating IP addresses for domain records. This provides
14
- dyndns-like functionality.
15
- EOF
16
- spec.summary = "A dyndns client for Cloudflare."
17
- spec.homepage = ""
18
- spec.license = "MIT"
19
-
20
- spec.files = `git ls-files`.split($/)
21
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
22
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
23
- spec.require_paths = ["lib"]
24
-
25
- spec.add_dependency "samovar", "~> 1.3"
26
- spec.add_dependency "tty-prompt", "~> 0.16.0"
27
- spec.add_dependency "cloudflare", "~> 4.0"
28
-
29
- spec.add_development_dependency 'async-rspec'
30
-
31
- spec.add_development_dependency "covered"
32
- spec.add_development_dependency "bundler"
33
- spec.add_development_dependency "rspec", "~> 3.6"
34
- spec.add_development_dependency "rake"
35
- end
@@ -1,40 +0,0 @@
1
-
2
- require 'cloudflare/dns/update/command'
3
-
4
- RSpec.describe Cloudflare::DNS::Update::Command::Top, order: :defined, timeout: 60 do
5
- include_context Cloudflare::RSpec::Connection
6
-
7
- let(:configuration_path) {File.join(__dir__, 'test.yaml')}
8
-
9
- subject{described_class.new(["-c", configuration_path])}
10
-
11
- let(:zone) {connection.zones.first}
12
- let!(:name) {"dyndns#{ENV['TRAVIS_JOB_ID']}"}
13
- let!(:qualified_name) {"#{name}.#{zone.name}"}
14
-
15
- it "should create dns record" do
16
- zone.dns_records.create("A", name, "127.0.0.1", ttl: 240, proxied: false)
17
- end
18
-
19
- let(:dns_record) {zone.dns_records.find_by_name(qualified_name)}
20
-
21
- it "should update dns record" do
22
- subject.connection = connection
23
-
24
- subject.configuration_store.transaction do |configuration|
25
- configuration[:content_command] = 'curl -s ipinfo.io/ip'
26
- configuration[:zone] = zone.value
27
- configuration[:domains] = [dns_record.value]
28
- end
29
-
30
- content = subject.update_domains
31
-
32
- response = dns_record.get
33
-
34
- expect(response.result[:content]).to be == content
35
- end
36
-
37
- it "should delete dns record" do
38
- expect(dns_record.delete).to be_success
39
- end
40
- end
@@ -1,12 +0,0 @@
1
-
2
- require 'covered/rspec'
3
- require "cloudflare/rspec/connection"
4
-
5
- RSpec.configure do |config|
6
- # Enable flags like --only-failures and --next-failure
7
- config.example_status_persistence_file_path = ".rspec_status"
8
-
9
- config.expect_with :rspec do |c|
10
- c.syntax = :expect
11
- end
12
- end