cloudflare-dns-update 2.0.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/bin/cloudflare-dns-update +1 -1
- data/lib/cloudflare/dns/update/command.rb +31 -6
- data/lib/cloudflare/dns/update/version.rb +1 -1
- data/spec/cloudflare/dns/update/command_spec.rb +3 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6233abf492347fbca6f5f3612c7f17c31bd3b899
|
4
|
+
data.tar.gz: 71393d51929cb97ff6ddda857370b7dc69f29dcb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d0c6f568e5f4c43a4200ed1c58ea544eb9cb23ea8c4c2c4a65c3654736b7fcaa634cc69538c33bc85ec66bb477045892c612ada9942184f6aecf0d6aa5b2032
|
7
|
+
data.tar.gz: a1524e97636719e1ac123c468ebfb26b796c9cdb51f6f3aa21741467614a8fd41d3b8de66318c96f1c97bb4dd06b58d7fa21e6ddd4ded9e1e041cbef512416f9
|
data/README.md
CHANGED
@@ -4,6 +4,8 @@ This gem provides a simple executable tool for managing Cloudflare records to pr
|
|
4
4
|
|
5
5
|
[![Build Status](https://secure.travis-ci.org/ioquatix/cloudflare-dns-update.svg)](http://travis-ci.org/ioquatix/cloudflare-dns-update)
|
6
6
|
|
7
|
+
[![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")
|
8
|
+
|
7
9
|
## Installation
|
8
10
|
|
9
11
|
Install it yourself as:
|
data/bin/cloudflare-dns-update
CHANGED
@@ -30,16 +30,41 @@ require_relative 'version'
|
|
30
30
|
|
31
31
|
module Cloudflare::DNS::Update
|
32
32
|
module Command
|
33
|
+
def self.parse(*args)
|
34
|
+
Top.parse(*args)
|
35
|
+
end
|
36
|
+
|
33
37
|
# The top level utopia command.
|
34
38
|
class Top < Samovar::Command
|
35
39
|
self.description = "Update remote DNS records according to locally run commands."
|
36
40
|
|
37
41
|
options do
|
38
42
|
option '-c/--configuration <path>', "Use the specified configuration file."
|
43
|
+
option '--verbose | --quiet', "Verbosity of output for debugging.", key: :logging
|
39
44
|
option '-h/--help', "Print out help information."
|
40
45
|
option '-v/--version', "Print out the application version."
|
41
46
|
end
|
42
47
|
|
48
|
+
def verbose?
|
49
|
+
@options[:logging] == :verbose
|
50
|
+
end
|
51
|
+
|
52
|
+
def quiet?
|
53
|
+
@options[:logging] == :quiet
|
54
|
+
end
|
55
|
+
|
56
|
+
def logger
|
57
|
+
@logger ||= Logger.new($stderr).tap do |logger|
|
58
|
+
if verbose?
|
59
|
+
logger.level = Logger::DEBUG
|
60
|
+
elsif quiet?
|
61
|
+
logger.level = Logger::WARN
|
62
|
+
else
|
63
|
+
logger.level = Logger::INFO
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
43
68
|
def prompt
|
44
69
|
@prompt ||= TTY::Prompt.new
|
45
70
|
end
|
@@ -95,14 +120,14 @@ module Cloudflare::DNS::Update
|
|
95
120
|
def initialize_command
|
96
121
|
configuration_store.transaction do |configuration|
|
97
122
|
unless configuration[:content_command]
|
98
|
-
configuration[:content_command] = prompt.ask("What command to get content for record?", default: 'curl ipinfo.io/ip')
|
123
|
+
configuration[:content_command] = prompt.ask("What command to get content for record?", default: 'curl -s ipinfo.io/ip')
|
99
124
|
end
|
100
125
|
end
|
101
126
|
end
|
102
127
|
|
103
128
|
def update_domains
|
104
129
|
configuration_store.transaction do |configuration|
|
105
|
-
|
130
|
+
logger.debug "Executing content command: #{configuration[:content_command]}"
|
106
131
|
content, status = Open3.capture2(configuration[:content_command])
|
107
132
|
|
108
133
|
unless status.success?
|
@@ -119,7 +144,7 @@ module Cloudflare::DNS::Update
|
|
119
144
|
|
120
145
|
configuration[:domains].each do |record|
|
121
146
|
if record[:content] != content
|
122
|
-
|
147
|
+
logger.info "Content changed #{content.inspect}, updating record..."
|
123
148
|
|
124
149
|
domain = zone.dns_records.find_by_id(record[:id])
|
125
150
|
|
@@ -132,13 +157,13 @@ module Cloudflare::DNS::Update
|
|
132
157
|
response = domain.put(changes.to_json, content_type: 'application/json')
|
133
158
|
|
134
159
|
if response.successful?
|
135
|
-
|
160
|
+
logger.info "Updated domain content to #{content}."
|
136
161
|
record[:content] = content
|
137
162
|
else
|
138
|
-
|
163
|
+
logger.warn "Failed to update domain content to #{content}: #{response.errors.join(', ')}!"
|
139
164
|
end
|
140
165
|
else
|
141
|
-
|
166
|
+
logger.debug "Content hasn't changed."
|
142
167
|
end
|
143
168
|
end
|
144
169
|
|
@@ -9,8 +9,8 @@ RSpec.describe Cloudflare::DNS::Update::Command::Top, order: :defined do
|
|
9
9
|
subject{described_class.new(["-c", configuration_path])}
|
10
10
|
|
11
11
|
let(:zone) {connection.zones.all.first}
|
12
|
-
let(:name) {"dyndns"}
|
13
|
-
let(:qualified_name) {"
|
12
|
+
let!(:name) {"dyndns#{ENV['TRAVIS_JOB_ID']}"}
|
13
|
+
let!(:qualified_name) {"#{name}.#{zone.record[:name]}"}
|
14
14
|
|
15
15
|
it "should create dns record" do
|
16
16
|
response = zone.dns_records.post({
|
@@ -29,10 +29,8 @@ RSpec.describe Cloudflare::DNS::Update::Command::Top, order: :defined do
|
|
29
29
|
it "should update dns record" do
|
30
30
|
subject.connection = connection
|
31
31
|
|
32
|
-
puts
|
33
|
-
|
34
32
|
subject.configuration_store.transaction do |configuration|
|
35
|
-
configuration[:content_command] = 'curl ipinfo.io/ip'
|
33
|
+
configuration[:content_command] = 'curl -s ipinfo.io/ip'
|
36
34
|
configuration[:zone] = zone.record
|
37
35
|
configuration[:domains] = [dns_record.record]
|
38
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudflare-dns-update
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: samovar
|