Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
CentralNic
php-epp
Commits
ae64058c
Unverified
Commit
ae64058c
authored
Jan 18, 2020
by
Nathan Van Overloop
Browse files
centralnic/issues#3886: consolidate trs_epp
parent
4e0c7d5c
Changes
10
Hide whitespace changes
Inline
Side-by-side
Net/EPP/Client.php
View file @
ae64058c
...
...
@@ -23,9 +23,9 @@
* @author Gavin Brown <gavin.brown@nospam.centralnic.com>
* @revision $Id: Client.php,v 1.13 2010/10/21 11:55:07 gavin Exp $
*/
require_once
(
'Protocol.php'
);
require_once
(
'
Net/EPP/
Protocol.php'
);
$GLOBALS
[
'Net_EPP_Client_Version'
]
=
'0.0.
5
'
;
$GLOBALS
[
'Net_EPP_Client_Version'
]
=
'0.0.
6
'
;
/**
* A simple client class for the Extensible Provisioning Protocol (EPP)
...
...
@@ -38,7 +38,6 @@
* @var resource the socket resource, once connected
*/
public
$socket
;
/**
* @var bool do output more debug messages
*/
...
...
@@ -59,7 +58,7 @@
$GLOBALS
[
'debug'
]
=
$debug
;
$this
->
socket
=
null
;
}
/**
* Establishes a connect to the server
* This method establishes the connection to the server. If the connection was
...
...
@@ -67,24 +66,26 @@
* frame which is sent by the server upon connection. If connection fails, then
* an exception with a message explaining the error will be thrown and handled
* in the calling code.
* @param string $host the hostname
* @param integer $port the TCP port
* @param integer $timeout the timeout in seconds
* @param boolean $ssl whether to connect using SSL
* @param resource $context a stream resource to use when setting up the socket connection
* @param string $host the hostname
* @param integer $port the TCP port
* @param integer $timeout the timeout in seconds
* @param boolean $ssl whether to connect using SSL
* @param resource $context a stream resource to use when setting up the socket connection
*@param string $protocol whether to use TLS or SSL
* @throws Exception on connection errors
* @return a string containing the server <greeting>
*/
public
function
connect
(
$host
,
$port
=
700
,
$timeout
=
1
,
$ssl
=
true
,
$context
=
null
)
public
function
connect
(
$host
,
$port
=
700
,
$timeout
=
1
,
$ssl
=
true
,
$context
=
null
,
$protocol
=
'tls'
)
{
if
(
$this
->
debug
)
{
syslog
(
LOG_INFO
,
"in connect"
);
}
$target
=
sprintf
(
'%s://%s:%d'
,
(
$ssl
===
true
?
'tls'
:
'tcp'
),
$host
,
$port
);
$target
=
sprintf
(
'%s://%s:%d'
,
(
$ssl
===
true
?
$protocol
:
'tcp'
),
$host
,
$port
);
if
(
$this
->
debug
)
{
syslog
(
LOG_INFO
,
"connecting to
{
$target
}
"
);
}
if
(
is_resource
(
$context
))
{
if
(
$this
->
debug
)
{
syslog
(
LOG_INFO
,
"using your provided context resource"
);
...
...
@@ -93,7 +94,6 @@
}
else
{
$result
=
stream_socket_client
(
$target
,
$errno
,
$errstr
,
$timeout
,
STREAM_CLIENT_CONNECT
);
}
if
(
is_resource
(
$result
))
{
if
(
$errno
==
0
)
{
if
(
$this
->
debug
)
{
...
...
@@ -117,14 +117,13 @@
}
}
// Set stream timeout
if
(
!
stream_set_timeout
(
$this
->
socket
,
$timeout
))
{
throw
new
Exception
(
"Failed to set timeout on socket:
$errstr
(code
$errno
)"
);
}
$this
->
timeout
=
$timeout
;
$GLOBALS
[
'timeout'
]
=
$timeout
;
// Set blocking
if
(
!
stream_set_blocking
(
$this
->
socket
,
0
))
{
throw
new
Exception
(
"Failed to set blocking on socket:
$errstr
(code
$errno
)"
);
...
...
Net/EPP/Frame/Command.php
View file @
ae64058c
...
...
@@ -22,9 +22,11 @@
$this
->
command
->
appendChild
(
$this
->
payload
);
}
}
function
addclTRID
(
$id
)
{
$this
->
clTRID
=
$this
->
createElement
(
'clTRID'
);
$this
->
clTRID
->
appendChild
(
$this
->
createTextNode
(
''
));
$this
->
clTRID
->
appendChild
(
$this
->
createTextNode
(
$id
));
$this
->
body
->
appendChild
(
$this
->
clTRID
);
}
...
...
@@ -42,23 +44,32 @@
return
$element
;
}
function
createObjectPropertyElement
(
$name
)
{
function
createObjectPropertyElement
(
$name
,
$type
=
NULL
)
{
$ns_type
=
isset
(
$type
)
?
$type
:
$this
->
type
;
$ns
=
!
empty
(
$ns_type
)
?
$ns_type
.
':'
.
$name
:
$name
;
return
$this
->
createElementNS
(
Net_EPP_ObjectSpec
::
xmlns
(
$this
->
type
),
$this
->
type
.
':'
.
$name
Net_EPP_ObjectSpec
::
xmlns
(
$ns_type
),
$ns
);
}
function
createExtension
Element
(
$ext
,
$command
)
{
function
createExtension
(
)
{
$this
->
extension
=
$this
->
createElement
(
'extension'
);
$this
->
body
->
appendChild
(
$this
->
extension
);
}
/**
* Creates an extension element with the option of specifying a custom namespace
* @param $ext
* @param $command
* @param null $version *
*/
function
createExtensionElement
(
$ext
,
$command
,
$version
=
null
)
{
$this
->
extension
->
payload
=
$this
->
createElementNS
(
Net_EPP_ObjectSpec
::
xmlns
(
$ext
),
Net_EPP_ObjectSpec
::
xmlns
(
$version
!==
null
?
$version
:
$ext
),
$ext
.
':'
.
$command
);
$this
->
extension
->
appendChild
(
$this
->
extension
->
payload
);
}
}
?>
Net/EPP/Frame/Command/Check/Contact.php
0 → 100644
View file @
ae64058c
<?php
/**
* @package Net_EPP
*/
class
Net_EPP_Frame_Command_Check_Contact
extends
Net_EPP_Frame_Command_Check
{
function
__construct
()
{
parent
::
__construct
(
'contact'
);
}
}
?>
Net/EPP/Frame/Command/Login.php
View file @
ae64058c
...
...
@@ -26,5 +26,15 @@
$this
->
command
->
appendChild
(
$this
->
svcs
);
}
function
addExtension
(
$exts
)
{
$extensions
=
$this
->
createElement
(
'svcExtension'
);
foreach
(
$exts
as
$ext
)
{
$ext_el
=
$this
->
createObjectPropertyElement
(
'extURI'
);
$ext_el
->
appendChild
(
$this
->
createTextNode
(
Net_EPP_ObjectSpec
::
xmlns
(
$ext
)));
$extensions
->
appendChild
(
$ext_el
);
}
$this
->
svcs
->
appendChild
(
$extensions
);
}
}
?>
Net/EPP/Frame/Command/Logout.php
0 → 100644
View file @
ae64058c
<?php
/**
* @package Net_EPP
*/
class
Net_EPP_Frame_Command_Logout
extends
Net_EPP_Frame_Command
{
function
__construct
()
{
parent
::
__construct
(
'logout'
);
}
}
?>
Net/EPP/Frame/Greeting.php
View file @
ae64058c
...
...
@@ -3,7 +3,7 @@
/**
* @package Net_EPP
*/
class
Net_EPP_Frame_Greeting
extends
Net_EPP_Frame
{
final
class
Net_EPP_Frame_Greeting
extends
Net_EPP_Frame
{
function
__construct
()
{
parent
::
__construct
(
'greeting'
);
...
...
Net/EPP/Frame/Hello.php
View file @
ae64058c
...
...
@@ -3,7 +3,7 @@
/**
* @package Net_EPP
*/
class
Net_EPP_Frame_Hello
extends
Net_EPP_Frame
{
final
class
Net_EPP_Frame_Hello
extends
Net_EPP_Frame
{
function
__construct
()
{
parent
::
__construct
(
'hello'
);
}
...
...
Net/EPP/Frame/Response.php
View file @
ae64058c
...
...
@@ -3,7 +3,7 @@
/**
* @package Net_EPP
*/
class
Net_EPP_Frame_Response
extends
Net_EPP_Frame
{
final
class
Net_EPP_Frame_Response
extends
Net_EPP_Frame
{
function
__construct
()
{
parent
::
__construct
(
'response'
);
}
...
...
Net/EPP/ObjectSpec.php
View file @
ae64058c
...
...
@@ -26,6 +26,61 @@
'id'
=>
'id'
,
'schema'
=>
'urn:ietf:params:xml:ns:rgp-1.0 rgp-1.0.xsd'
,
),
'launch'
=>
array
(
'xmlns'
=>
'urn:ietf:params:xml:ns:launch-1.0'
,
'id'
=>
'id'
,
'schema'
=>
'urn:ar:params:xml:ns:launch-1.0 launch-1.0.xsd'
,
),
'idn'
=>
array
(
'xmlns'
=>
'urn:ietf:params:xml:ns:idn-1.0'
,
'id'
=>
'id'
,
'schema'
=>
'urn:ar:params:xml:ns:idn-1.0 idn-1.0.xsd'
,
),
'tmch'
=>
array
(
'xmlns'
=>
'urn:ar:params:xml:ns:tmch-1.0'
,
'id'
=>
'id'
,
'schema'
=>
'urn:ar:params:xml:ns:tmch-1.0 tmch-1.0.xsd'
,
),
'application'
=>
array
(
'xmlns'
=>
'urn:ar:params:xml:ns:application-1.0'
,
'id'
=>
'id'
,
'schema'
=>
'urn:ar:params:xml:ns:application-1.0 application-1.0.xsd'
,
),
'price'
=>
array
(
'xmlns'
=>
'urn:ar:params:xml:ns:price-1.0'
,
'id'
=>
'id'
,
'schema'
=>
'urn:ar:params:xml:ns:price-1.0 price-1.0.xsd'
,
),
'asia'
=>
array
(
'xmlns'
=>
'urn:ar:params:xml:ns:asia-1.0'
,
'id'
=>
'id'
,
'schema'
=>
'urn:ar:params:xml:ns:asia-1.0 asia-1.0.xsd'
,
),
'signedMark'
=>
array
(
'xmlns'
=>
'urn:ietf:params:xml:ns:signedMark-1.0'
,
'id'
=>
'domain'
,
'schema'
=>
'urn:ietf:params:xml:ns:signedMark-1.0 signedMark-1.0.xsd'
,
),
'fee'
=>
array
(
'xmlns'
=>
'urn:ietf:params:xml:ns:fee-0.5'
,
'id'
=>
'domain'
,
'schema'
=>
'urn:ietf:params:xml:ns:fee-0.5 fee-0.5.xsd'
,
),
'fee_23'
=>
array
(
'xmlns'
=>
'urn:ietf:params:xml:ns:fee-0.23'
,
'id'
=>
'domain'
,
'schema'
=>
'urn:ietf:params:xml:ns:fee-0.23 fee-0.23.xsd'
,
),
'allocationToken'
=>
array
(
'xmlns'
=>
'urn:ietf:params:xml:ns:allocationToken-1.0'
,
'id'
=>
'domain'
,
'schema'
=>
'urn:ietf:params:xml:ns:allocationToken-1.0 allocationToken-1.0.xsd'
,
),
'auxcontact'
=>
array
(
'xmlns'
=>
'urn:ietf:params:xml:ns:auxcontact-0.1'
,
'id'
=>
'domain'
,
'schema'
=>
'urn:ietf:params:xml:ns:auxcontact-0.1 auxcontact-1.0.xsd'
,
),
);
static
function
id
(
$object
)
{
...
...
Net/EPP/Protocol.php
View file @
ae64058c
...
...
@@ -41,7 +41,7 @@ class Net_EPP_Protocol
while
(
!
$info
[
'timed_out'
]
&&
!
feof
(
$socket
))
{
//make sure we don't wait to long
if
(
$time
out_time
<
microtime
(
true
)
)
{
if
(
(
$time
_end
-
$time_start
)
>
10000000
)
{
$time_diff
=
microtime
(
true
)
-
$time_start
;
throw
new
exception
(
"Timeout reading from EPP server after
$time_diff
seconds"
);
}
...
...
@@ -71,6 +71,7 @@ class Net_EPP_Protocol
$time_diff
=
(
microtime
(
true
)
-
$time_start
)
*
1000
;
syslog
(
LOG_INFO
,
"returning after
{
$time_diff
}
ms"
);
}
return
$result
;
}
...
...
@@ -115,6 +116,7 @@ class Net_EPP_Protocol
if
(
$info
[
'timed_out'
])
{
throw
new
Exception
(
'Timeout while writing data to socket'
);
}
return
$pos
;
}
...
...
@@ -135,7 +137,6 @@ class Net_EPP_Protocol
if
(
$GLOBALS
[
'debug'
])
{
syslog
(
LOG_INFO
,
"read header successfully containing "
.
var_dump
(
$hdr
));
}
// Unpack first 4 bytes which is our length
$unpacked
=
unpack
(
'N'
,
$hdr
);
$length
=
$unpacked
[
1
];
...
...
@@ -158,12 +159,10 @@ class Net_EPP_Protocol
public
static
function
sendFrame
(
$socket
,
$xml
)
{
$length
=
strlen
(
$xml
)
+
4
;
if
(
$GLOBALS
[
'debug'
])
{
syslog
(
LOG_INFO
,
"length of the header is ${length} about to write ${xml}"
);
}
// Grab XML length & add on 4 bytes for the counter
$res
=
Net_EPP_Protocol
::
_fwrite_nb
(
$socket
,
pack
(
'N'
,
$length
)
.
$xml
,
$length
);
// Check our write matches
if
(
$length
!=
$res
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment