inwxupdate 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/lib/detectors/detector.rb +25 -8
- data/lib/detectors/ifconfig.rb +8 -1
- data/lib/detectors/ipify.rb +9 -1
- data/lib/detectors/ruby.rb +24 -0
- data/lib/detectors/timestamp.rb +10 -0
- data/lib/inwx.rb +2 -0
- data/lib/inwxupdate.rb +3 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca12c4a0d61084e1ca666c3367454555b2dca10d
|
4
|
+
data.tar.gz: b6d5006de0d613a30625fe3f65508199287a59ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65971323673dc858410af80afa53919ee200aa3121b66aa1f40db1e1843a7025dc9809e86c3fa1db219d7e0a8b3a9fc9c026028d99180aea788c15782c3182f8
|
7
|
+
data.tar.gz: 85ba97c3d1e92385448572d8325f32addc47d803289e28c2c347c757f04878dba3036d59f26ebe1a24cf625ae94513ec67e0045163cadbc9e14e0b94a3e5b271
|
data/lib/detectors/detector.rb
CHANGED
@@ -1,11 +1,28 @@
|
|
1
|
+
# Wraps around different detector implementations
|
1
2
|
module Detector
|
2
|
-
def self.setup(
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
def self.setup(params)
|
4
|
+
ifconfig(params) ||
|
5
|
+
ipify(params) ||
|
6
|
+
ruby_sockets(params) ||
|
7
|
+
timestamp(params)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.ifconfig(params)
|
11
|
+
return unless params[:type] == 'ifconfig' && params[:version] == 6
|
12
|
+
|
13
|
+
Ifconfig.new(params[:network_interface], params[:version])
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.ipify(params)
|
17
|
+
return unless params[:type] == 'ipify'
|
18
|
+
Ipify.new(params[:network_interface], params[:version])
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.ruby_sockets(params)
|
22
|
+
Ruby.new(params[:version]) if params[:type] == 'ruby'
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.timestamp(params)
|
26
|
+
Timestamp.new if params[:type] == 'timestamp'
|
10
27
|
end
|
11
28
|
end
|
data/lib/detectors/ifconfig.rb
CHANGED
@@ -7,7 +7,14 @@ class Ifconfig
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def detect
|
10
|
-
|
10
|
+
command = [
|
11
|
+
"ifconfig #{@network_interface} inet6",
|
12
|
+
'grep inet6',
|
13
|
+
'grep -v fe80',
|
14
|
+
'grep -v deprecated'
|
15
|
+
].join(' | ')
|
16
|
+
|
17
|
+
raw = `#{command}`
|
11
18
|
ip = raw.lstrip.split(' ')[1]
|
12
19
|
|
13
20
|
raise 'no ip detected' unless ip
|
data/lib/detectors/ipify.rb
CHANGED
@@ -10,7 +10,15 @@ class Ipify
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def detect
|
13
|
-
|
13
|
+
command = [
|
14
|
+
'curl',
|
15
|
+
"-#{@version}",
|
16
|
+
"--interface #{@network_interface}",
|
17
|
+
"'https://api.ipify.org?format=text'",
|
18
|
+
'-s'
|
19
|
+
].join(' ')
|
20
|
+
|
21
|
+
ip = `#{command}`
|
14
22
|
|
15
23
|
raise 'no ip detected' unless ip
|
16
24
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'socket'
|
3
|
+
|
4
|
+
# Detects your current IP via Ruby Sockets
|
5
|
+
class Ruby
|
6
|
+
def initialize(version)
|
7
|
+
@version = version == 6 ? 6 : 4
|
8
|
+
end
|
9
|
+
|
10
|
+
def detect
|
11
|
+
ip_addresses =
|
12
|
+
if @version == 6
|
13
|
+
Socket.ip_address_list.select(&:ipv6?).reject(&:ipv6_loopback?)
|
14
|
+
else
|
15
|
+
Socket.ip_address_list.select(&:ipv4?).reject(&:ipv4_loopback?)
|
16
|
+
end
|
17
|
+
|
18
|
+
ip = ip_addresses.first.ip_address
|
19
|
+
|
20
|
+
raise 'no ip detected' unless ip
|
21
|
+
|
22
|
+
ip
|
23
|
+
end
|
24
|
+
end
|
data/lib/inwx.rb
CHANGED
@@ -22,6 +22,7 @@ end
|
|
22
22
|
|
23
23
|
# Implements the convienience
|
24
24
|
class APIObject
|
25
|
+
# rubocop:disable Style/MethodMissing
|
25
26
|
def self.method_missing(*args)
|
26
27
|
args = [name.downcase] + args
|
27
28
|
|
@@ -31,6 +32,7 @@ class APIObject
|
|
31
32
|
|
32
33
|
result['resData']
|
33
34
|
end
|
35
|
+
# rubocop:enable Style/MethodMissing
|
34
36
|
end
|
35
37
|
|
36
38
|
class Account < APIObject; end
|
data/lib/inwxupdate.rb
CHANGED
@@ -4,9 +4,12 @@ require_relative 'inwx.rb'
|
|
4
4
|
require_relative 'detectors/detector.rb'
|
5
5
|
require_relative 'detectors/ifconfig.rb'
|
6
6
|
require_relative 'detectors/ipify.rb'
|
7
|
+
require_relative 'detectors/ruby.rb'
|
8
|
+
require_relative 'detectors/timestamp.rb'
|
7
9
|
|
8
10
|
require 'simpleidn'
|
9
11
|
|
12
|
+
# Update inwx DNS records
|
10
13
|
class Inwxupdate
|
11
14
|
def run
|
12
15
|
find_config!
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inwxupdate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steffen Schröder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simpleidn
|
@@ -35,11 +35,13 @@ files:
|
|
35
35
|
- lib/detectors/detector.rb
|
36
36
|
- lib/detectors/ifconfig.rb
|
37
37
|
- lib/detectors/ipify.rb
|
38
|
+
- lib/detectors/ruby.rb
|
39
|
+
- lib/detectors/timestamp.rb
|
38
40
|
- lib/inwx.rb
|
39
41
|
- lib/inwxupdate.rb
|
40
42
|
homepage: https://github.com/ChaosSteffen/inwxupdate
|
41
43
|
licenses:
|
42
|
-
- BSD
|
44
|
+
- BSD-2-Clause
|
43
45
|
metadata: {}
|
44
46
|
post_install_message:
|
45
47
|
rdoc_options: []
|