smart_proxy_dns_inwx 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e923717a022d5cf2a26a482bf665c7e5076ec328
4
- data.tar.gz: 7d089f6d2458990b2b481ebfd5b6b300ac543e57
3
+ metadata.gz: 7eac9c8252b1ec26260d1472e4deeef084f8b89f
4
+ data.tar.gz: 46f1c3b36d673b7dfa55f2424a765fa186db8751
5
5
  SHA512:
6
- metadata.gz: 2405ca7b802617976cbe23ab1ed7a009a129c510ea82f7e529aa8837c85bf5227518bd46396a10026100304441ff7c8077487c384412c3c0f357909aee24e646
7
- data.tar.gz: ef85642695fcc1b7839aad3ee5de6f5c33b2b19443613de00de3a1df6c4f6eb9edb64f45296f282e56070fc094ceb67c24ad4221f92786eae813ac82b0aa3224
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/Domrobot'
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(options)
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 create
26
- method = "createRecord"
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, "#{@fqdn} is already used") unless ip == @value
28
+ raise(Proxy::Dns::Collision, "#{name} is already used") unless ip == value
30
29
  else
31
- domain, name = split_fqdn(@fqdn)
32
- params = {:domain => domain, :type => @type, :content => @value, :name => name }
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 #{@type} DNS entry #{name} => #{@value} to domain #{domain}"
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 remove
42
- ip, id = dns_find(@fqdn)
43
- raise Proxy::Dns::NotFound.new("Cannot find DNS entry for #{@fqdn}") unless id
44
- msg = "remove DNS entry #{@fqdn} => #{@value}"
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
- domain = fqdn.split('.')[-2..-1].join('.')
71
- name = fqdn.chomp(".#{domain}")
72
- [domain,name]
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"] ]
@@ -1,7 +1,7 @@
1
1
  module Proxy
2
2
  module Dns
3
3
  module Inwx
4
- VERSION = '0.5.0'
4
+ VERSION = '0.6.0'
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_proxy_dns_inwx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clemens Bergmann