smart_proxy_dns_inwx 0.5.0 → 0.6.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7eac9c8252b1ec26260d1472e4deeef084f8b89f
|
4
|
+
data.tar.gz: 46f1c3b36d673b7dfa55f2424a765fa186db8751
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cbe8d753bda325c8e69e90bb8ca51d7a40de268a84101485f87a74b4e5ccf387af3303e5404f87cee370f29d2d813d44a3d206a19b59e1352a7580b620ea456
|
7
|
+
data.tar.gz: 027d3e202770bfd5b2514e6434daba1efa6bf52cc5f3869b2097c9b83504fd4fe4b712db69aba91d75c1f29b7b00ace5a572de68ac805eaefc871b062ecb58dc
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'resolv'
|
2
2
|
require 'resolv-replace'
|
3
3
|
require 'yaml'
|
4
|
-
require 'inwx/
|
4
|
+
require 'inwx/domrobot'
|
5
5
|
|
6
6
|
module Proxy::Dns::Inwx
|
7
7
|
class Record < ::Proxy::Dns::Record
|
@@ -11,37 +11,37 @@ module Proxy::Dns::Inwx
|
|
11
11
|
attr_accessor :domrobot
|
12
12
|
attr_accessor :object
|
13
13
|
|
14
|
-
def initialize(inwx_user,inwx_pass)
|
14
|
+
def initialize(inwx_user, inwx_pass, ttl = nil)
|
15
15
|
addr = "api.domrobot.com"
|
16
16
|
@object = "nameserver"
|
17
17
|
@domrobot = INWX::Domrobot.new(addr)
|
18
18
|
result = self.domrobot.login(inwx_user,inwx_pass)
|
19
|
-
super(
|
19
|
+
super(nil, ttl)
|
20
20
|
end
|
21
21
|
|
22
22
|
# create({ :fqdn => "node01.lab", :value => "192.168.100.2"}
|
23
23
|
# create({ :fqdn => "node01.lab", :value => "3.100.168.192.in-addr.arpa",
|
24
24
|
# :type => "PTR"}
|
25
|
-
def
|
26
|
-
|
27
|
-
ip, id = dns_find(@fqdn)
|
25
|
+
def do_create(name, value, type)
|
26
|
+
ip, id = dns_find(name)
|
28
27
|
if ip
|
29
|
-
raise(Proxy::Dns::Collision, "#{
|
28
|
+
raise(Proxy::Dns::Collision, "#{name} is already used") unless ip == value
|
30
29
|
else
|
31
|
-
domain, name = split_fqdn(
|
32
|
-
|
30
|
+
domain, name = split_fqdn(name)
|
31
|
+
method = "createRecord"
|
32
|
+
params = {:domain => domain, :type => type, :content => value, :name => name }
|
33
33
|
result = self.domrobot.call(self.object, method, params)
|
34
|
-
msg = "add #{
|
34
|
+
msg = "add #{type} DNS entry #{name} => #{value} to domain #{domain}"
|
35
35
|
report msg, result["msg"], false
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
# remove({ :fqdn => "node01.lab", :value => "192.168.100.2"}
|
40
40
|
# remove({ :fqdn => "node01.lab", :value => "3.100.168.192.in-addr.arpa"}
|
41
|
-
def
|
42
|
-
ip, id = dns_find(
|
43
|
-
raise Proxy::Dns::NotFound.new("Cannot find DNS entry for #{
|
44
|
-
msg = "remove DNS entry #{
|
41
|
+
def do_remove(name, value)
|
42
|
+
ip, id = dns_find(name)
|
43
|
+
raise Proxy::Dns::NotFound.new("Cannot find DNS entry for #{name}") unless id
|
44
|
+
msg = "remove DNS entry #{name} => #{value}"
|
45
45
|
method = "deleteRecord"
|
46
46
|
params = { :id => id }
|
47
47
|
result = self.domrobot.call(self.object, method, params)
|
@@ -50,7 +50,11 @@ module Proxy::Dns::Inwx
|
|
50
50
|
end
|
51
51
|
|
52
52
|
private
|
53
|
-
|
53
|
+
|
54
|
+
def resolver
|
55
|
+
@resolver ||= Resolv::DNS.new
|
56
|
+
end
|
57
|
+
|
54
58
|
def report msg, response, error_only=false
|
55
59
|
if not response.include? "completed successfully"
|
56
60
|
logger.error "Inwx failed:\n" + response.join("\n")
|
@@ -67,18 +71,23 @@ module Proxy::Dns::Inwx
|
|
67
71
|
end
|
68
72
|
|
69
73
|
def split_fqdn fqdn
|
70
|
-
|
71
|
-
|
72
|
-
|
74
|
+
method = "list"
|
75
|
+
params = { :pagelimit => 0 }
|
76
|
+
result = self.domrobot.call(self.object, method, params)
|
77
|
+
result["resData"]["domains"].each do |domain|
|
78
|
+
domain=domain["domain"]
|
79
|
+
if fqdn.end_with?(domain)
|
80
|
+
return [domain,fqdn.chomp(".#{domain}")]
|
81
|
+
end
|
82
|
+
end
|
83
|
+
raise Proxy::Dns::Error.new("Could not find domain for host #{fqdn}")
|
73
84
|
end
|
74
85
|
|
75
86
|
def dns_find fqdn
|
76
87
|
domain, name = split_fqdn(fqdn)
|
77
88
|
method = "info"
|
78
89
|
params = { :domain => domain, :name => name }
|
79
|
-
logger.error params.inspect
|
80
90
|
result = self.domrobot.call(self.object, method, params)
|
81
|
-
logger.error result.inspect
|
82
91
|
return false if result["resData"]["record"].nil?
|
83
92
|
|
84
93
|
return [ result["resData"]["record"][0]["content"], result["resData"]["record"][0]["id"] ]
|