loopiator 0.3.8 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/loopiator.rb +4 -2
- data/lib/loopiator/client.rb +3 -1
- data/lib/loopiator/configuration.rb +1 -1
- data/lib/loopiator/credits.rb +1 -1
- data/lib/loopiator/dns.rb +31 -0
- data/lib/loopiator/domains.rb +12 -6
- data/lib/loopiator/errors.rb +1 -1
- data/lib/loopiator/extensions/hash.rb +0 -1
- data/lib/loopiator/logger.rb +1 -1
- data/lib/loopiator/models/dns_record.rb +36 -0
- data/lib/loopiator/models/domain.rb +1 -1
- data/lib/loopiator/patch.rb +107 -0
- data/lib/loopiator/railtie.rb +1 -1
- data/lib/loopiator/utilities.rb +1 -1
- data/loopiator.gemspec +4 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e337f46983f27ebc24f64efef5356dcf51910f0
|
4
|
+
data.tar.gz: c8721b31e995554baec96c8e35ef8efe5e413be2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d50ea50d5779d22f44e2106e1a6080a5148810d74906e0a434226b686e681bda4643b4521093844064e4aa99edc1e3a35fb843395be603650a245d0eaa41803a
|
7
|
+
data.tar.gz: 4495cb58ddbb7d2f5689290099123ce17c7d8c61e5d4ba9afd7e0f319142291a1a598d972286e77840fbfea17ed23f8419f4d4f4c82b91cf9c4e44decffe933f
|
data/lib/loopiator.rb
CHANGED
@@ -5,12 +5,14 @@ require File.join(File.dirname(__FILE__), 'loopiator/logger')
|
|
5
5
|
require File.join(File.dirname(__FILE__), 'loopiator/errors')
|
6
6
|
require File.join(File.dirname(__FILE__), 'loopiator/utilities')
|
7
7
|
require File.join(File.dirname(__FILE__), 'loopiator/models/domain')
|
8
|
+
require File.join(File.dirname(__FILE__), 'loopiator/models/dns_record')
|
8
9
|
require File.join(File.dirname(__FILE__), 'loopiator/domains')
|
10
|
+
require File.join(File.dirname(__FILE__), 'loopiator/dns')
|
9
11
|
require File.join(File.dirname(__FILE__), 'loopiator/credits')
|
10
12
|
require File.join(File.dirname(__FILE__), 'loopiator/client')
|
11
13
|
|
12
14
|
module Loopiator
|
13
|
-
VERSION = "0.
|
15
|
+
VERSION = "0.4.0"
|
14
16
|
|
15
17
|
class << self
|
16
18
|
attr_writer :configuration
|
@@ -28,4 +30,4 @@ module Loopiator
|
|
28
30
|
yield(configuration)
|
29
31
|
end
|
30
32
|
|
31
|
-
end
|
33
|
+
end
|
data/lib/loopiator/client.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'xmlrpc/client'
|
2
|
+
require File.join(File.dirname(__FILE__), 'patch') # Needed to convert <i4> to <int> - Loopia's XML RPC server won't accept <i4> as a valid method signature
|
2
3
|
require 'simpleidn'
|
3
4
|
|
4
5
|
module Loopiator
|
@@ -50,6 +51,7 @@ module Loopiator
|
|
50
51
|
end
|
51
52
|
|
52
53
|
include Loopiator::Domains
|
54
|
+
include Loopiator::Dns
|
53
55
|
include Loopiator::Credits
|
54
56
|
|
55
57
|
private
|
@@ -94,4 +96,4 @@ module Loopiator
|
|
94
96
|
end
|
95
97
|
|
96
98
|
end
|
97
|
-
end
|
99
|
+
end
|
data/lib/loopiator/credits.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
module Loopiator
|
2
|
+
module Dns
|
3
|
+
|
4
|
+
def get_zone_records(domain, subdomain, customer_number: "")
|
5
|
+
records = []
|
6
|
+
response = call("getZoneRecords", customer_number, encode_domain(domain), subdomain)
|
7
|
+
|
8
|
+
response.each do |item|
|
9
|
+
records << Loopiator::Models::DnsRecord.new(item)
|
10
|
+
end if response && response.is_a?(Array)
|
11
|
+
|
12
|
+
return records
|
13
|
+
end
|
14
|
+
|
15
|
+
def add_zone_record(domain, subdomain, record_obj, customer_number: "")
|
16
|
+
response = parse_status_response(call("addZoneRecord", customer_number, encode_domain(domain), subdomain, record_obj))
|
17
|
+
return response.eql?(:ok)
|
18
|
+
end
|
19
|
+
|
20
|
+
def remove_zone_record(domain, subdomain, record_id, customer_number: "")
|
21
|
+
response = parse_status_response(call("removeZoneRecord", customer_number, encode_domain(domain), subdomain, record_id))
|
22
|
+
return response.eql?(:ok)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
def encode_domain(domain_name)
|
27
|
+
Loopiator::Utilities.encode_domain(domain_name)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
data/lib/loopiator/domains.rb
CHANGED
@@ -11,7 +11,7 @@ module Loopiator
|
|
11
11
|
domain = nil
|
12
12
|
response = call("getDomain", customer_number, encode_domain(domain_name))
|
13
13
|
|
14
|
-
if
|
14
|
+
if response && response.is_a?(Hash)
|
15
15
|
domain = Loopiator::Models::Domain.new(response)
|
16
16
|
end
|
17
17
|
|
@@ -24,7 +24,7 @@ module Loopiator
|
|
24
24
|
|
25
25
|
response.each do |item|
|
26
26
|
domains << Loopiator::Models::Domain.new(item)
|
27
|
-
end if
|
27
|
+
end if response && response.is_a?(Array)
|
28
28
|
|
29
29
|
return domains
|
30
30
|
end
|
@@ -51,10 +51,16 @@ module Loopiator
|
|
51
51
|
return success
|
52
52
|
end
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
def update_nameservers(domain, nameservers = ['ns1.loopia.se', 'ns2.loopia.se'], customer_number: "")
|
55
|
+
response = parse_status_response(call("updateDNSServers", customer_number, encode_domain(domain), nameservers))
|
56
|
+
|
57
|
+
return response.eql?(:ok)
|
57
58
|
end
|
58
59
|
|
60
|
+
private
|
61
|
+
def encode_domain(domain_name)
|
62
|
+
Loopiator::Utilities.encode_domain(domain_name)
|
63
|
+
end
|
64
|
+
|
59
65
|
end
|
60
|
-
end
|
66
|
+
end
|
data/lib/loopiator/errors.rb
CHANGED
data/lib/loopiator/logger.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
module Loopiator
|
2
|
+
module Models
|
3
|
+
|
4
|
+
#https://www.loopia.se/api/record_obj/
|
5
|
+
class DnsRecord
|
6
|
+
attr_accessor :record_id, :type, :ttl, :priority, :rdata
|
7
|
+
|
8
|
+
def initialize(hash = nil)
|
9
|
+
if hash && hash.is_a?(Hash) && !hash.empty?
|
10
|
+
hash.symbolize_keys!
|
11
|
+
|
12
|
+
self.record_id = hash.fetch(:record_id, nil)
|
13
|
+
self.type = hash.fetch(:type, "").to_s
|
14
|
+
self.ttl = hash.fetch(:ttl, 3_600).to_i
|
15
|
+
self.priority = hash.fetch(:priority, 0).to_i
|
16
|
+
self.rdata = hash.fetch(:rdata, "").to_s
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_h
|
21
|
+
data = {
|
22
|
+
type: self.type,
|
23
|
+
ttl: self.ttl,
|
24
|
+
priority: self.priority,
|
25
|
+
rdata: self.rdata
|
26
|
+
}
|
27
|
+
|
28
|
+
data[:record_id] = self.record_id if self.record_id
|
29
|
+
|
30
|
+
return data
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
module XMLRPC
|
2
|
+
class Create
|
3
|
+
private
|
4
|
+
|
5
|
+
def conv2value(param) # :doc:
|
6
|
+
val = case param
|
7
|
+
when Integer
|
8
|
+
# XML-RPC's int is 32bit int
|
9
|
+
if Config::ENABLE_BIGINT
|
10
|
+
@writer.tag("int", param.to_s)
|
11
|
+
else
|
12
|
+
if param >= -(2**31) and param <= (2**31-1)
|
13
|
+
@writer.tag("int", param.to_s)
|
14
|
+
else
|
15
|
+
raise "Integer is too big! Must be signed 32-bit integer!"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
when TrueClass, FalseClass
|
19
|
+
@writer.tag("boolean", param ? "1" : "0")
|
20
|
+
|
21
|
+
when Symbol
|
22
|
+
@writer.tag("string", param.to_s)
|
23
|
+
|
24
|
+
when String
|
25
|
+
@writer.tag("string", param)
|
26
|
+
|
27
|
+
when NilClass
|
28
|
+
if Config::ENABLE_NIL_CREATE
|
29
|
+
@writer.ele("nil")
|
30
|
+
else
|
31
|
+
raise "Wrong type NilClass. Not allowed!"
|
32
|
+
end
|
33
|
+
|
34
|
+
when Float
|
35
|
+
raise "Wrong value #{param}. Not allowed!" unless param.finite?
|
36
|
+
@writer.tag("double", param.to_s)
|
37
|
+
|
38
|
+
when Struct
|
39
|
+
h = param.members.collect do |key|
|
40
|
+
value = param[key]
|
41
|
+
@writer.ele("member",
|
42
|
+
@writer.tag("name", key.to_s),
|
43
|
+
conv2value(value)
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
@writer.ele("struct", *h)
|
48
|
+
|
49
|
+
when Hash
|
50
|
+
# TODO: can a Hash be empty?
|
51
|
+
|
52
|
+
h = param.collect do |key, value|
|
53
|
+
@writer.ele("member",
|
54
|
+
@writer.tag("name", key.to_s),
|
55
|
+
conv2value(value)
|
56
|
+
)
|
57
|
+
end
|
58
|
+
|
59
|
+
@writer.ele("struct", *h)
|
60
|
+
|
61
|
+
when Array
|
62
|
+
# TODO: can an Array be empty?
|
63
|
+
a = param.collect {|v| conv2value(v) }
|
64
|
+
|
65
|
+
@writer.ele("array",
|
66
|
+
@writer.ele("data", *a)
|
67
|
+
)
|
68
|
+
|
69
|
+
when Time, Date, ::DateTime
|
70
|
+
@writer.tag("dateTime.iso8601", param.strftime("%Y%m%dT%H:%M:%S"))
|
71
|
+
|
72
|
+
when XMLRPC::DateTime
|
73
|
+
@writer.tag("dateTime.iso8601",
|
74
|
+
format("%.4d%02d%02dT%02d:%02d:%02d", *param.to_a))
|
75
|
+
|
76
|
+
when XMLRPC::Base64
|
77
|
+
@writer.tag("base64", param.encoded)
|
78
|
+
|
79
|
+
else
|
80
|
+
if Config::ENABLE_MARSHALLING and param.class.included_modules.include? XMLRPC::Marshallable
|
81
|
+
# convert Ruby object into Hash
|
82
|
+
ret = {"___class___" => param.class.name}
|
83
|
+
param.instance_variables.each {|v|
|
84
|
+
name = v[1..-1]
|
85
|
+
val = param.instance_variable_get(v)
|
86
|
+
|
87
|
+
if val.nil?
|
88
|
+
ret[name] = val if Config::ENABLE_NIL_CREATE
|
89
|
+
else
|
90
|
+
ret[name] = val
|
91
|
+
end
|
92
|
+
}
|
93
|
+
return conv2value(ret)
|
94
|
+
else
|
95
|
+
ok, pa = wrong_type(param)
|
96
|
+
if ok
|
97
|
+
return conv2value(pa)
|
98
|
+
else
|
99
|
+
raise "Wrong type!"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
@writer.ele("value", val)
|
105
|
+
end
|
106
|
+
end # class Create
|
107
|
+
end # module XMLRPC
|
data/lib/loopiator/railtie.rb
CHANGED
data/lib/loopiator/utilities.rb
CHANGED
data/loopiator.gemspec
CHANGED
@@ -3,7 +3,7 @@ Gem::Specification.new do |s|
|
|
3
3
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.3.5") if s.respond_to? :required_rubygems_version=
|
4
4
|
|
5
5
|
s.name = 'loopiator'
|
6
|
-
s.version = '0.
|
6
|
+
s.version = '0.4.0'
|
7
7
|
|
8
8
|
s.homepage = "https://github.com/Agiley/Loopiator"
|
9
9
|
s.email = "sebastian@agiley.se"
|
@@ -27,11 +27,14 @@ Gem::Specification.new do |s|
|
|
27
27
|
lib/loopiator/client.rb
|
28
28
|
lib/loopiator/configuration.rb
|
29
29
|
lib/loopiator/credits.rb
|
30
|
+
lib/loopiator/dns.rb
|
30
31
|
lib/loopiator/domains.rb
|
31
32
|
lib/loopiator/errors.rb
|
32
33
|
lib/loopiator/extensions/hash.rb
|
33
34
|
lib/loopiator/logger.rb
|
35
|
+
lib/loopiator/models/dns_record.rb
|
34
36
|
lib/loopiator/models/domain.rb
|
37
|
+
lib/loopiator/patch.rb
|
35
38
|
lib/loopiator/railtie.rb
|
36
39
|
lib/loopiator/utilities.rb
|
37
40
|
loopiator.gemspec
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: loopiator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Johnsson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simpleidn
|
@@ -67,11 +67,14 @@ files:
|
|
67
67
|
- lib/loopiator/client.rb
|
68
68
|
- lib/loopiator/configuration.rb
|
69
69
|
- lib/loopiator/credits.rb
|
70
|
+
- lib/loopiator/dns.rb
|
70
71
|
- lib/loopiator/domains.rb
|
71
72
|
- lib/loopiator/errors.rb
|
72
73
|
- lib/loopiator/extensions/hash.rb
|
73
74
|
- lib/loopiator/logger.rb
|
75
|
+
- lib/loopiator/models/dns_record.rb
|
74
76
|
- lib/loopiator/models/domain.rb
|
77
|
+
- lib/loopiator/patch.rb
|
75
78
|
- lib/loopiator/railtie.rb
|
76
79
|
- lib/loopiator/utilities.rb
|
77
80
|
- loopiator.gemspec
|