epp 1.0.10 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +3 -3
- data/VERSION +1 -1
- data/lib/epp.rb +0 -1
- data/lib/epp/server.rb +53 -34
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -46,15 +46,15 @@ You would then make an XML request to the server.
|
|
46
46
|
|
47
47
|
You can build this however you'd like. The process is as follows:
|
48
48
|
|
49
|
-
* Connect to EPP server
|
49
|
+
* Connect to EPP server and receive the <greeting> frame
|
50
50
|
* Send a standard <login> request
|
51
51
|
* Send your request
|
52
52
|
* Send a standard <logout> request
|
53
53
|
* Disconnect the socket from the server
|
54
54
|
|
55
|
-
The EPP
|
55
|
+
The EPP module would then return the XML response as a string. In this example, the response XML would be set equal to <tt>response</tt> for your usage.
|
56
56
|
|
57
|
-
Once the request is complete, it will automatically close the connection. For simplicity purposes, this plug-in will *not* use a persistent connection to the EPP server.
|
57
|
+
Once the request is complete, it will automatically close the connection. For simplicity purposes, this plug-in will *not* use a persistent connection to the EPP server. This may change in future releases, as some registries require that persistent connections be supported. Please feel free to email me to collaborate on making this possible.
|
58
58
|
|
59
59
|
== Bugs/Issues
|
60
60
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0
|
1
|
+
1.1.0
|
data/lib/epp.rb
CHANGED
data/lib/epp/server.rb
CHANGED
@@ -2,7 +2,7 @@ module Epp #:nodoc:
|
|
2
2
|
class Server
|
3
3
|
include RequiresParameters
|
4
4
|
|
5
|
-
attr_accessor :tag, :password, :server, :port, :
|
5
|
+
attr_accessor :tag, :password, :server, :port, :old_server, :lang, :extensions, :version
|
6
6
|
|
7
7
|
# ==== Required Attrbiutes
|
8
8
|
#
|
@@ -14,18 +14,25 @@ module Epp #:nodoc:
|
|
14
14
|
#
|
15
15
|
# * <tt>:port</tt> - The EPP standard port is 700. However, you can choose a different port to use.
|
16
16
|
# * <tt>:clTRID</tt> - The client transaction identifier is an element that EPP specifies MAY be used to uniquely identify the command to the server. You are responsible for maintaining your own transaction identifier space to ensure uniqueness. Defaults to "ABC-12345"
|
17
|
-
# * <tt>:old_server</tt> - Set to true to read and write frames in a way that is compatible with
|
17
|
+
# * <tt>:old_server</tt> - Set to true to read and write frames in a way that is compatible with older EPP servers. Default is false.
|
18
18
|
# * <tt>:lang</tt> - Set custom language attribute. Default is 'en'.
|
19
|
+
# * <tt>:services</tt> - Use custom EPP services in the <login> frame. The defaults use the EPP standard domain, contact and host 1.0 services.
|
20
|
+
# * <tt>:extensions</tt> - URLs to custom extensions to standard EPP. Use these to extend the standard EPP (e.g., Nominet uses extensions). Defaults to none.
|
21
|
+
# * <tt>:version</tt> - Set the EPP version. Defaults to "1.0".
|
19
22
|
def initialize(attributes = {})
|
20
23
|
requires!(attributes, :tag, :password, :server)
|
21
24
|
|
22
25
|
@tag = attributes[:tag]
|
23
26
|
@password = attributes[:password]
|
24
27
|
@server = attributes[:server]
|
25
|
-
@port = attributes[:port]
|
26
|
-
@clTRID = attributes[:clTRID] || "ABC-12345"
|
28
|
+
@port = attributes[:port] || 700
|
27
29
|
@old_server = attributes[:old_server] || false
|
28
|
-
@lang = attributes[:lang]
|
30
|
+
@lang = attributes[:lang] || 'en'
|
31
|
+
@services = attributes[:services] || ["urn:ietf:params:xml:ns:domain-1.0", "urn:ietf:params:xml:ns:contact-1.0", "urn:ietf:params:xml:ns:host-1.0"]
|
32
|
+
@extensions = attributes[:extensions] || []
|
33
|
+
@version = attributes[:verison] || "1.0"
|
34
|
+
|
35
|
+
@logged_in = false
|
29
36
|
end
|
30
37
|
|
31
38
|
# Sends an XML request to the EPP server, and receives an XML response.
|
@@ -35,35 +42,26 @@ module Epp #:nodoc:
|
|
35
42
|
def request(xml)
|
36
43
|
open_connection
|
37
44
|
|
45
|
+
@logged_in = true if login
|
46
|
+
|
38
47
|
begin
|
39
|
-
login
|
40
48
|
@response = send_request(xml)
|
41
49
|
ensure
|
42
|
-
|
50
|
+
if @logged_in && !@old_server
|
51
|
+
@logged_in = false if logout
|
52
|
+
end
|
53
|
+
|
43
54
|
close_connection
|
44
55
|
end
|
45
56
|
|
46
57
|
return @response
|
47
58
|
end
|
48
59
|
|
49
|
-
|
50
|
-
|
51
|
-
# Wrapper which sends an XML frame to the server, and receives
|
52
|
-
# the response frame in return.
|
53
|
-
def send_request(xml)
|
54
|
-
send_frame(xml)
|
55
|
-
response = get_frame
|
56
|
-
end
|
60
|
+
private
|
57
61
|
|
62
|
+
# Sends a standard login request to the EPP server.
|
58
63
|
def login
|
59
|
-
xml =
|
60
|
-
xml << REXML::XMLDecl.new("1.0", "UTF-8", "no")
|
61
|
-
|
62
|
-
xml.add_element("epp", {
|
63
|
-
"xmlns" => "urn:ietf:params:xml:ns:epp-1.0",
|
64
|
-
"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
|
65
|
-
"xsi:schemaLocation" => "urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd"
|
66
|
-
})
|
64
|
+
xml = new_epp_request
|
67
65
|
|
68
66
|
command = xml.root.add_element("command")
|
69
67
|
login = command.add_element("login")
|
@@ -72,7 +70,7 @@ module Epp #:nodoc:
|
|
72
70
|
login.add_element("pw").text = @password
|
73
71
|
|
74
72
|
options = login.add_element("options")
|
75
|
-
options.add_element("version").text =
|
73
|
+
options.add_element("version").text = @version
|
76
74
|
options.add_element("lang").text = @lang
|
77
75
|
|
78
76
|
services = login.add_element("svcs")
|
@@ -80,6 +78,13 @@ module Epp #:nodoc:
|
|
80
78
|
services.add_element("objURI").text = "urn:ietf:params:xml:ns:contact-1.0"
|
81
79
|
services.add_element("objURI").text = "urn:ietf:params:xml:ns:host-1.0"
|
82
80
|
|
81
|
+
# Include schema extensions for registrars which require it
|
82
|
+
extensions_container = services.add_element("svcExtension") unless @extensions.empty?
|
83
|
+
|
84
|
+
for uri in @extensions
|
85
|
+
extensions_container.add_element("extURI").text = uri
|
86
|
+
end
|
87
|
+
|
83
88
|
command.add_element("clTRID").text = @clTRID
|
84
89
|
|
85
90
|
# Receive the login response
|
@@ -95,15 +100,9 @@ module Epp #:nodoc:
|
|
95
100
|
end
|
96
101
|
end
|
97
102
|
|
103
|
+
# Sends a standard logout request to the EPP server.
|
98
104
|
def logout
|
99
|
-
xml =
|
100
|
-
xml << REXML::XMLDecl.new("1.0", "UTF-8", "no")
|
101
|
-
|
102
|
-
xml.add_element('epp', {
|
103
|
-
'xmlns' => "urn:ietf:params:xml:ns:epp-1.0",
|
104
|
-
'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance",
|
105
|
-
'xsi:schemaLocation' => "urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd"
|
106
|
-
})
|
105
|
+
xml = new_epp_request
|
107
106
|
|
108
107
|
command = xml.root.add_element("command")
|
109
108
|
login = command.add_element("logout")
|
@@ -121,6 +120,26 @@ module Epp #:nodoc:
|
|
121
120
|
end
|
122
121
|
end
|
123
122
|
|
123
|
+
def new_epp_request
|
124
|
+
xml = REXML::Document.new
|
125
|
+
xml << REXML::XMLDecl.new("1.0", "UTF-8", "no")
|
126
|
+
|
127
|
+
xml.add_element("epp", {
|
128
|
+
"xmlns" => "urn:ietf:params:xml:ns:epp-1.0",
|
129
|
+
"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
|
130
|
+
"xsi:schemaLocation" => "urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd"
|
131
|
+
})
|
132
|
+
|
133
|
+
return xml
|
134
|
+
end
|
135
|
+
|
136
|
+
# Wrapper which sends an XML frame to the server, and receives
|
137
|
+
# the response frame in return.
|
138
|
+
def send_request(xml)
|
139
|
+
send_frame(xml)
|
140
|
+
get_frame
|
141
|
+
end
|
142
|
+
|
124
143
|
# Establishes the connection to the server. If the connection is
|
125
144
|
# established, then this method will call get_frame and return
|
126
145
|
# the EPP <tt><greeting></tt> frame which is sent by the
|
@@ -199,8 +218,8 @@ module Epp #:nodoc:
|
|
199
218
|
# Send an XML frame to the server. Should return the total byte
|
200
219
|
# size of the frame sent to the server. If the socket returns EOF,
|
201
220
|
# the connection has closed and a SocketError is raised.
|
202
|
-
def send_frame(xml)
|
203
|
-
|
221
|
+
def send_frame(xml)
|
222
|
+
@socket.write(@old_server ? (xml + "\r\n") : ([xml.size + 4].pack("N") + xml))
|
204
223
|
end
|
205
224
|
end
|
206
225
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Delsman
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-19 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|