do-dyndns 0.3.0 → 0.4.0
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.
- checksums.yaml +4 -4
- data/bin/console +1 -1
- data/bin/do_dyndns +14 -0
- data/config.example.yml +9 -0
- data/lib/do_dyndns/updater.rb +15 -16
- data/lib/do_dyndns/version.rb +1 -1
- metadata +13 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a45320eb7b5dd1d027f5c12daa59498f6e861ca38005b6fc80ec559106ba0f43
|
4
|
+
data.tar.gz: cc4f5886a47dd1f86c5f6cd297d2c90a1b785b8066b4868ca6f5344e2d40ed29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 489d3253a1c6ed719158254bd2a246f6f63a0a79a6ed62f8908d470731825793954656b5603613a8e8e148a60c59f8bac077466185a41888b214cccac6c9108f
|
7
|
+
data.tar.gz: 727165fd149526b1dd4cc6edd28b896361755046a34188331cde0a4a92c19d0af67903bbcd5e4a54dcd3235703e7fd9f71028ed1b5ea2801115eb911592047c3
|
data/bin/console
CHANGED
data/bin/do_dyndns
CHANGED
@@ -17,6 +17,20 @@ config_path = File.expand_path "~/.config/do-dyndns.yml"
|
|
17
17
|
|
18
18
|
if File.exist? config_path
|
19
19
|
config = YAML.load_file config_path
|
20
|
+
|
21
|
+
key_missing = false
|
22
|
+
%i[token domains ipv4_commands ipv6_commands].each do |key|
|
23
|
+
unless config.key?(key)
|
24
|
+
key_missing = true
|
25
|
+
$stderr.puts "missing configuration: `:#{key}`"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
if key_missing
|
30
|
+
$stderr.puts "\nExample configuration:\n\n```yml\n#{File.read("../config.example.yml")}\n```"
|
31
|
+
exit 1
|
32
|
+
end
|
33
|
+
|
20
34
|
DoDyndns::Updater.new(**config, logger: LOG).update_ips
|
21
35
|
else
|
22
36
|
LOG.warn "No configuration exists @ #{config_path}: Creating file."
|
data/config.example.yml
CHANGED
@@ -1,4 +1,13 @@
|
|
1
1
|
:token: your_digital_ocean_token_here
|
2
|
+
|
2
3
|
:domains:
|
3
4
|
example-domain1.com:
|
4
5
|
- example-subdomain1
|
6
|
+
|
7
|
+
:ipv4_commands:
|
8
|
+
- "dig -4 @ns1-1.akamaitech.net ANY whoami.akamai.net +short"
|
9
|
+
- "dig -4 @ns1.google.com ANY o-o.myaddr.l.google.com +short"
|
10
|
+
|
11
|
+
:ipv6_commands:
|
12
|
+
- "dig -6 @resolver1.opendns.com ANY myip.opendns.com +short"
|
13
|
+
- "dig -6 @ns1.google.com ANY o-o.myaddr.l.google.com +short"
|
data/lib/do_dyndns/updater.rb
CHANGED
@@ -2,9 +2,14 @@ module DoDyndns
|
|
2
2
|
class Updater
|
3
3
|
require 'droplet_kit'
|
4
4
|
|
5
|
-
|
5
|
+
IPV4_RE = /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/m
|
6
|
+
IPV6_RE = /(?:\:{,2}[A-Z\d]{1,4}\:{,2}){1,8}/im
|
7
|
+
|
8
|
+
def initialize(token:, domains:, ipv4_commands:, ipv6_commands:, logger: Logger.new($stdout))
|
6
9
|
@logger = logger
|
7
10
|
@domains = domains
|
11
|
+
@ipv4_commands = ipv4_commands
|
12
|
+
@ipv6_commands = ipv6_commands
|
8
13
|
@api = DropletKit::Client.new(access_token: token)
|
9
14
|
end
|
10
15
|
|
@@ -57,30 +62,24 @@ module DoDyndns
|
|
57
62
|
end
|
58
63
|
|
59
64
|
def wan_ipv4
|
60
|
-
resolve(
|
61
|
-
"dig -4 @resolver1.opendns.com ANY myip.opendns.com +short",
|
62
|
-
"dig -4 @ns1-1.akamaitech.net ANY whoami.akamai.net +short",
|
63
|
-
"dig -4 @ns1.google.com ANY o-o.myaddr.l.google.com +short"
|
64
|
-
])
|
65
|
+
resolve(@ipv4_commands, regex: IPV4_RE)
|
65
66
|
end
|
66
67
|
|
67
68
|
def wan_ipv6
|
68
|
-
resolve(
|
69
|
-
"dig -6 @resolver1.opendns.com ANY myip.opendns.com +short",
|
70
|
-
"dig -6 @ns1.google.com ANY o-o.myaddr.l.google.com +short"
|
71
|
-
])
|
69
|
+
resolve(@ipv6_commands, regex: IPV6_RE)
|
72
70
|
end
|
73
71
|
|
74
72
|
private
|
75
73
|
|
76
74
|
# Try all the commands until one of them works
|
77
|
-
def resolve(commands)
|
75
|
+
def resolve(commands, regex:)
|
78
76
|
_ip = nil
|
79
|
-
commands.each do |
|
80
|
-
|
81
|
-
_ip =
|
77
|
+
commands.each do |command|
|
78
|
+
result = `#{command}`
|
79
|
+
_ip = result[regex]
|
80
|
+
break if _ip
|
82
81
|
end
|
83
|
-
_ip
|
82
|
+
_ip
|
84
83
|
end
|
85
84
|
end
|
86
|
-
end
|
85
|
+
end
|
data/lib/do_dyndns/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: do-dyndns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Clink
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -30,42 +30,42 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 13.0.6
|
34
34
|
type: :development
|
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:
|
40
|
+
version: 13.0.6
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3.
|
47
|
+
version: '3.11'
|
48
48
|
type: :development
|
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: '3.
|
54
|
+
version: '3.11'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: droplet_kit
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 3.
|
61
|
+
version: 3.18.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 3.
|
68
|
+
version: 3.18.0
|
69
69
|
description: |
|
70
70
|
Finds the wan IPv4 address of the server it's running on and
|
71
71
|
updates the corresponding DNS records on digital ocean.
|
@@ -84,11 +84,11 @@ files:
|
|
84
84
|
- lib/do_dyndns.rb
|
85
85
|
- lib/do_dyndns/updater.rb
|
86
86
|
- lib/do_dyndns/version.rb
|
87
|
-
homepage:
|
87
|
+
homepage: https://github.com/SleepingInsomniac/dyndns
|
88
88
|
licenses:
|
89
89
|
- MIT
|
90
90
|
metadata: {}
|
91
|
-
post_install_message:
|
91
|
+
post_install_message:
|
92
92
|
rdoc_options: []
|
93
93
|
require_paths:
|
94
94
|
- lib
|
@@ -103,8 +103,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '0'
|
105
105
|
requirements: []
|
106
|
-
rubygems_version: 3.
|
107
|
-
signing_key:
|
106
|
+
rubygems_version: 3.3.7
|
107
|
+
signing_key:
|
108
108
|
specification_version: 4
|
109
109
|
summary: Automatically update DNS records on DigitalOcean
|
110
110
|
test_files: []
|