dps 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/dps/dns.rb +11 -10
- data/lib/dps/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6bcfbdc8e0ef48e5c38505ca0d5e08ad4976f78e0cd242f1a57215ceae46da6
|
4
|
+
data.tar.gz: '0568d8eebea462377ad1ce3ba3c8a41e079308f5620bcb2855f9750d9d3c0c0b'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a3c88359398b5f95436eb103691496b13844177d16d4864dd226e1ad0f3b06cbca493f4a9646cd26c7ff4727bc31a93f11562ed130923a2dfc3276f2bcac948
|
7
|
+
data.tar.gz: 5b4fa1290ed2a10a79ab8717076d92425709342f26dd3275fa64346948cbfb4f800165e375bd66a7d34da255848d7963038149323c9809587717e2b632ea0af1
|
data/Gemfile.lock
CHANGED
data/lib/dps/dns.rb
CHANGED
@@ -3,12 +3,9 @@ require 'dnsruby'
|
|
3
3
|
module DPS
|
4
4
|
class DNS
|
5
5
|
|
6
|
-
class NoRecords; end
|
7
|
-
class TooManyRecords; end
|
8
|
-
|
9
6
|
class << self
|
10
7
|
def get_records(domain)
|
11
|
-
|
8
|
+
get_txt_records(domain).
|
12
9
|
collect { |value| decode_txt_record(value) }.select(&:valid?)
|
13
10
|
end
|
14
11
|
|
@@ -17,12 +14,14 @@ module DPS
|
|
17
14
|
|
18
15
|
# Reverse since Ruby #pop starts from end of list.
|
19
16
|
parts.reverse!
|
17
|
+
action = parts.pop
|
18
|
+
parts.reverse!
|
20
19
|
|
21
|
-
case
|
20
|
+
case action
|
22
21
|
when "dps:endpoint"
|
23
22
|
Endpoint.new(parts)
|
24
23
|
else
|
25
|
-
InvalidRecord
|
24
|
+
InvalidRecord.new("Unexpected action '#{action}'")
|
26
25
|
end
|
27
26
|
end
|
28
27
|
|
@@ -30,9 +29,9 @@ module DPS
|
|
30
29
|
records = get_records(domain).select { |r| r.is_a?(Endpoint) }
|
31
30
|
|
32
31
|
if records.length > 1
|
33
|
-
TooManyRecords
|
32
|
+
TooManyRecords.new
|
34
33
|
elsif records.length == 0
|
35
|
-
NoRecords
|
34
|
+
NoRecords.new
|
36
35
|
else
|
37
36
|
records[0]
|
38
37
|
end
|
@@ -40,7 +39,7 @@ module DPS
|
|
40
39
|
|
41
40
|
private
|
42
41
|
|
43
|
-
def
|
42
|
+
def get_txt_records(domain)
|
44
43
|
result = []
|
45
44
|
|
46
45
|
::Dnsruby::DNS.open do |dns|
|
@@ -52,7 +51,9 @@ module DPS
|
|
52
51
|
end
|
53
52
|
end
|
54
53
|
|
55
|
-
class
|
54
|
+
class NoRecords < StandardError; end
|
55
|
+
class TooManyRecords < StandardError; end
|
56
|
+
class InvalidRecord < StandardError
|
56
57
|
def self.valid?
|
57
58
|
false
|
58
59
|
end
|
data/lib/dps/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mat Holroyd
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dnsruby
|