epp-client-base 0.14.0 → 0.15.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 +5 -5
- data/Rakefile +4 -5
- data/epp-client-base.gemspec +4 -4
- data/lib/epp-client/base.rb +22 -18
- data/lib/epp-client/connection.rb +21 -29
- data/lib/epp-client/contact.rb +180 -181
- data/lib/epp-client/domain.rb +180 -185
- data/lib/epp-client/exceptions.rb +1 -0
- data/lib/epp-client/poll.rb +19 -19
- data/lib/epp-client/session.rb +24 -28
- data/lib/epp-client/ssl.rb +9 -12
- data/lib/epp-client/version.rb +1 -1
- data/lib/epp-client/xml.rb +51 -54
- metadata +2 -2
data/lib/epp-client/poll.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
module EPPClient
|
2
|
+
# This implements the poll EPP commands.
|
2
3
|
module Poll
|
3
4
|
def poll_req_xml #:nodoc:
|
4
5
|
command do |xml|
|
5
|
-
|
6
|
+
xml.poll(:op => :req)
|
6
7
|
end
|
7
8
|
end
|
8
9
|
|
@@ -28,33 +29,32 @@ module EPPClient
|
|
28
29
|
|
29
30
|
def poll_req_process(xml) #:nodoc:
|
30
31
|
ret = {}
|
31
|
-
if (date = xml.xpath(
|
32
|
-
|
32
|
+
if (date = xml.xpath('epp:msgQ/epp:qDate', EPPClient::SCHEMAS_URL)).size > 0
|
33
|
+
ret[:qDate] = DateTime.parse(date.text)
|
33
34
|
end
|
34
|
-
if (msg = xml.xpath(
|
35
|
-
|
36
|
-
|
35
|
+
if (msg = xml.xpath('epp:msgQ/epp:msg', EPPClient::SCHEMAS_URL)).size > 0
|
36
|
+
ret[:msg] = msg.text
|
37
|
+
ret[:msg_xml] = msg.to_s
|
37
38
|
end
|
38
39
|
if (obj = xml.xpath('epp:resData', EPPClient::SCHEMAS_URL)).size > 0 ||
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
40
|
+
(obj = xml.xpath('epp:extension', EPPClient::SCHEMAS_URL)).size > 0
|
41
|
+
ret[:obj_xml] = obj.to_s
|
42
|
+
PARSERS.each do |xpath, parser|
|
43
|
+
next unless obj.xpath(xpath, EPPClient::SCHEMAS_URL).size > 0
|
44
|
+
ret[:obj] = case parser
|
45
|
+
when Symbol
|
46
|
+
send(parser, xml)
|
47
|
+
else
|
48
|
+
fail NotImplementedError
|
49
|
+
end
|
50
|
+
end
|
51
51
|
end
|
52
52
|
ret
|
53
53
|
end
|
54
54
|
|
55
55
|
def poll_ack_xml(mid) #:nodoc:
|
56
56
|
command do |xml|
|
57
|
-
|
57
|
+
xml.poll(:op => :ack, :msgID => mid)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
data/lib/epp-client/session.rb
CHANGED
@@ -1,36 +1,34 @@
|
|
1
1
|
module EPPClient
|
2
|
+
# This handles the basic session, login, logout, and hello.
|
2
3
|
module Session
|
3
|
-
|
4
4
|
# Sends an hello epp command.
|
5
5
|
def hello
|
6
|
-
send_request(command
|
7
|
-
xml.hello
|
8
|
-
end)
|
6
|
+
send_request(command(&:hello))
|
9
7
|
end
|
10
8
|
|
11
9
|
def login_xml(new_pw = nil) #:nodoc:
|
12
10
|
command do |xml|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
11
|
+
xml.login do
|
12
|
+
xml.clID(@client_id)
|
13
|
+
xml.pw(@password)
|
14
|
+
xml.newPW(new_pw) unless new_pw.nil?
|
15
|
+
xml.options do
|
16
|
+
xml.version(@version)
|
17
|
+
xml.lang(@lang)
|
18
|
+
end
|
19
|
+
xml.svcs do
|
20
|
+
services.each do |s|
|
21
|
+
xml.objURI(s)
|
22
|
+
end
|
23
|
+
unless extensions.empty?
|
24
|
+
xml.svcExtension do
|
25
|
+
extensions.each do |e|
|
26
|
+
xml.extURI(e)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
34
32
|
end
|
35
33
|
end
|
36
34
|
private :login_xml
|
@@ -46,9 +44,7 @@ module EPPClient
|
|
46
44
|
# Performs the logout command, after it, the server terminates the
|
47
45
|
# connection.
|
48
46
|
def logout
|
49
|
-
response = send_request(command
|
50
|
-
xml.logout
|
51
|
-
end)
|
47
|
+
response = send_request(command(&:logout))
|
52
48
|
|
53
49
|
get_result(response)
|
54
50
|
end
|
data/lib/epp-client/ssl.rb
CHANGED
@@ -1,32 +1,29 @@
|
|
1
1
|
module EPPClient
|
2
|
+
# This module handles the SSL strangeness that happens with EPP.
|
2
3
|
module SSL
|
3
4
|
attr_reader :ssl_cert, :ssl_key
|
4
5
|
|
5
6
|
def ssl_key=(key) #:nodoc:
|
6
7
|
case key
|
7
8
|
when OpenSSL::PKey::RSA
|
8
|
-
|
9
|
+
@ssl_key = key
|
9
10
|
when String
|
10
|
-
|
11
|
-
|
12
|
-
end
|
13
|
-
@ssl_key = OpenSSL::PKey::RSA.new(key)
|
11
|
+
key = File.read(key) unless key =~ /-----BEGIN RSA PRIVATE KEY-----/
|
12
|
+
@ssl_key = OpenSSL::PKey::RSA.new(key)
|
14
13
|
else
|
15
|
-
|
14
|
+
fail ArgumentError, 'Must either be an OpenSSL::PKey::RSA object, a filename or a key'
|
16
15
|
end
|
17
16
|
end
|
18
17
|
|
19
18
|
def ssl_cert=(cert) #:nodoc:
|
20
19
|
case cert
|
21
20
|
when OpenSSL::X509::Certificate
|
22
|
-
|
21
|
+
@ssl_cert = cert
|
23
22
|
when String
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
-
@ssl_cert = OpenSSL::X509::Certificate.new(cert)
|
23
|
+
cert = File.read(cert) unless cert =~ /-----BEGIN CERTIFICATE-----/
|
24
|
+
@ssl_cert = OpenSSL::X509::Certificate.new(cert)
|
28
25
|
else
|
29
|
-
|
26
|
+
fail ArgumentError, 'Must either be an OpenSSL::X509::Certificate object, a filename or a certificate'
|
30
27
|
end
|
31
28
|
end
|
32
29
|
|
data/lib/epp-client/version.rb
CHANGED
data/lib/epp-client/xml.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
module EPPClient
|
2
|
+
# This handles all the XML I/O
|
2
3
|
module XML
|
3
|
-
|
4
4
|
attr_reader :sent_xml, :recv_xml, :msgQ_count, :msgQ_id, :trID
|
5
5
|
|
6
6
|
# Parses a frame and returns a Nokogiri::XML::Document.
|
7
7
|
def parse_xml(string) #:doc:
|
8
8
|
Nokogiri::XML::Document.parse(string) do |opts|
|
9
|
-
|
10
|
-
|
9
|
+
opts.options = 0
|
10
|
+
opts.noblanks
|
11
11
|
end
|
12
12
|
end
|
13
13
|
private :parse_xml
|
@@ -15,13 +15,13 @@ module EPPClient
|
|
15
15
|
def recv_frame_to_xml #:nodoc:
|
16
16
|
@recv_xml = parse_xml(@recv_frame)
|
17
17
|
puts @recv_xml.to_s.gsub(/^/, '<< ') if debug
|
18
|
-
|
18
|
+
@recv_xml
|
19
19
|
end
|
20
20
|
|
21
21
|
def sent_frame_to_xml #:nodoc:
|
22
22
|
@send_xml = parse_xml(@sent_frame)
|
23
23
|
puts @send_xml.to_s.gsub(/^/, '>> ') if debug
|
24
|
-
|
24
|
+
@send_xml
|
25
25
|
end
|
26
26
|
|
27
27
|
def raw_builder(opts = {}) #:nodoc:
|
@@ -32,10 +32,10 @@ module EPPClient
|
|
32
32
|
# creates a Builder::XmlMarkup object, mostly only used by +command+
|
33
33
|
def builder(opts = {})
|
34
34
|
raw_builder(opts) do |xml|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
xml.instruct! :xml, :version => '1.0', :encoding => 'UTF-8'
|
36
|
+
xml.epp('xmlns' => EPPClient::SCHEMAS_URL['epp'], 'xmlns:epp' => EPPClient::SCHEMAS_URL['epp']) do
|
37
|
+
yield xml
|
38
|
+
end
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -49,51 +49,48 @@ module EPPClient
|
|
49
49
|
# In case there was a problem, an EPPErrorResponse exception is raised.
|
50
50
|
def get_result(args)
|
51
51
|
xml = case args
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
52
|
+
when Hash
|
53
|
+
args.delete(:xml)
|
54
|
+
else
|
55
|
+
xml = args
|
56
|
+
args = {}
|
57
|
+
xml
|
58
|
+
end
|
59
59
|
|
60
60
|
args[:range] ||= 1000..1999
|
61
61
|
|
62
62
|
if (mq = xml.xpath('epp:epp/epp:response/epp:msgQ', EPPClient::SCHEMAS_URL)).size > 0
|
63
|
-
|
64
|
-
|
65
|
-
|
63
|
+
@msgQ_count = mq.attribute('count').value.to_i
|
64
|
+
@msgQ_id = mq.attribute('id').value
|
65
|
+
puts "DEBUG: MSGQ : count=#{@msgQ_count}, id=#{@msgQ_id}\n" if debug
|
66
66
|
else
|
67
|
-
|
68
|
-
|
67
|
+
@msgQ_count = 0
|
68
|
+
@msgQ_id = nil
|
69
69
|
end
|
70
70
|
|
71
71
|
if (trID = xml.xpath('epp:epp/epp:response/epp:trID', EPPClient::SCHEMAS_URL)).size > 0
|
72
|
-
|
72
|
+
@trID = get_trid(trID)
|
73
73
|
end
|
74
74
|
|
75
75
|
res = xml.xpath('epp:epp/epp:response/epp:result', EPPClient::SCHEMAS_URL)
|
76
76
|
code = res.attribute('code').value.to_i
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
else
|
86
|
-
return true
|
87
|
-
end
|
77
|
+
|
78
|
+
fail EPPClient::EPPErrorResponse.new(:xml => xml, :code => code, :message => res.xpath('epp:msg', EPPClient::SCHEMAS_URL).text) unless args[:range].include?(code)
|
79
|
+
|
80
|
+
return true unless args.key?(:callback)
|
81
|
+
|
82
|
+
case cb = args[:callback]
|
83
|
+
when Symbol
|
84
|
+
return send(cb, xml.xpath('epp:epp/epp:response', EPPClient::SCHEMAS_URL))
|
88
85
|
else
|
89
|
-
|
86
|
+
fail ArgumentError, 'Invalid callback type'
|
90
87
|
end
|
91
88
|
end
|
92
89
|
|
93
90
|
def get_trid(xml)
|
94
91
|
{
|
95
|
-
|
96
|
-
|
92
|
+
:clTRID => xml.xpath('epp:clTRID', EPPClient::SCHEMAS_URL).text,
|
93
|
+
:svTRID => xml.xpath('epp:svTRID', EPPClient::SCHEMAS_URL).text,
|
97
94
|
}
|
98
95
|
end
|
99
96
|
|
@@ -114,31 +111,31 @@ module EPPClient
|
|
114
111
|
# end, lambda do |xml|
|
115
112
|
# xml.extension
|
116
113
|
# end)
|
117
|
-
def command(*args, &
|
114
|
+
def command(*args, &_block)
|
118
115
|
builder do |xml|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
116
|
+
xml.command do
|
117
|
+
if block_given?
|
118
|
+
yield xml
|
119
|
+
else
|
120
|
+
command = args.shift
|
121
|
+
command.call(xml)
|
122
|
+
args.each do |ext|
|
123
|
+
xml.extension do
|
124
|
+
ext.call(xml)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
xml.clTRID(clTRID)
|
129
|
+
end
|
133
130
|
end
|
134
131
|
end
|
135
132
|
|
136
133
|
# Wraps the content in an epp:extension.
|
137
134
|
def extension
|
138
135
|
raw_builder do |xml|
|
139
|
-
|
140
|
-
|
141
|
-
|
136
|
+
xml.extension do
|
137
|
+
yield(xml)
|
138
|
+
end
|
142
139
|
end
|
143
140
|
end
|
144
141
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epp-client-base
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mathieu Arnold
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2016-02-
|
12
|
+
date: 2016-02-17 00:00:00 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|