Commit 8bc90889 authored by Scott's avatar Scott
Browse files

Integrate other ZACR SLDs.



- Remove server address and port from config parameters array.
- Add SLD lookup helper function to provide information to client and
  registration functions.
- Provide domain name to client function. Needed for SLD lookups.

Signed-off-by: Scott's avatarScott Barr <scott@barr.co.za>
parent 20c71670
......@@ -44,8 +44,6 @@ function cozaepp_getConfigArray() {
$configarray = array(
"Username" => array( "Type" => "text", "Size" => "20", "Description" => "Enter your username here" ),
"Password" => array( "Type" => "password", "Size" => "20", "Description" => "Enter your password here" ),
"Server" => array( "Type" => "text", "Size" => "20", "Description" => "Enter EPP Server Address" ),
"Port" => array( "Type" => "text", "Size" => "20", "Description" => "Enter EPP Server Port" ),
"SSL" => array( "Type" => "yesno" ),
"Certificate" => array( "Type" => "text", "Description" => "Path of certificate .pem" )
);
......@@ -72,7 +70,7 @@ function cozaepp_GetNameservers($params) {
# Get client instance
try {
$client = _cozaepp_Client();
$client = _cozaepp_Client($domain);
# Get list of nameservers for domain
$result = $client->request($xml = '
......@@ -168,7 +166,7 @@ function cozaepp_SaveNameservers($params) {
# Get client instance
try {
$client = _cozaepp_Client();
$client = _cozaepp_Client($domain);
# Grab list of current nameservers
$request = $client->request( $xml = '
......@@ -285,12 +283,13 @@ function cozaepp_SaveRegistrarLock($params) {
# Function to retrieve an available contact id
function _cozaepp_CheckContact($prehash) {
$domain = $prehash;
$prehash = $prehash . time() . rand(0, 1000000);
$contactid = substr(md5($prehash), 0,15);
# Get client instance and check for available contact id
try {
$client = _cozaepp_Client();
$client = _cozaepp_Client($domain);
$contactAvailable = 0;
$count = 0;
......@@ -425,7 +424,7 @@ function cozaepp_RegisterDomain($params) {
# Get client instance
try {
$client = _cozaepp_Client();
$client = _cozaepp_Client($domain);
# Send registration
$request = $client->request($xml = '
......@@ -562,7 +561,7 @@ function cozaepp_TransferDomain($params) {
# Get client instance
try {
$client = _cozaepp_Client();
$client = _cozaepp_Client($domain);
# Initiate transfer
$request = $client->request($xml = '
......@@ -661,7 +660,7 @@ function cozaepp_RenewDomain($params) {
# Get client instance
try {
$client = _cozaepp_Client();
$client = _cozaepp_Client($domain);
# Send renewal request
$request = $client->request($xml = '
......@@ -739,7 +738,7 @@ function _getContactDetails($domain, $client = null) {
# Get client instance
try {
if (!isset($client)) {
$client = _cozaepp_Client();
$client = _cozaepp_Client($domain);
}
# Grab domain info
......@@ -961,7 +960,7 @@ function cozaepp_SaveContactDetails($params) {
# Get client instance
try {
$client = _cozaepp_Client();
$client = _cozaepp_Client($domain);
# Grab domain info
$request = $client->request($xml = '
......@@ -1081,7 +1080,7 @@ function cozaepp_RegisterNameserver($params) {
# Grab client instance
try {
$client = _cozaepp_Client();
$client = _cozaepp_Client($domain);
# Register nameserver
$request = $client->request($xml = '
......@@ -1146,7 +1145,7 @@ function cozaepp_ModifyNameserver($params) {
# Grab client instance
try {
$client = _cozaepp_Client();
$client = _cozaepp_Client($domain);
# Modify nameserver
$request = $client->request($xml = '
......@@ -1207,7 +1206,7 @@ function cozaepp_DeleteNameserver($params) {
# Grab client instance
try {
$client = _cozaepp_Client();
$client = _cozaepp_Client($domain);
# If we were given hostname. blow away all of the stuff behind it and allow us to remove hostname
$nameserver = preg_replace('/\.\.\S+/','',$nameserver);
......@@ -1289,8 +1288,49 @@ function _cozaepp_ackpoll($client,$msgid) {
}
}
# Helper function to centrally provide data and information
# about different SLDs.
function _cozaepp_SldLookup($domain) {
# TLD server data provided by ZACR
$tldservers = array(
'co.za' => array(
'fqdn' => 'epp.coza.net.za',
'port' => 3121,
'additional_contacts' => false
),
'org.za' => array(
'fqdn' => 'org-epp.registry.net.za',
'port' => 3121,
'additional_contacts' => true
),
'web.za' => array(
'fqdn' => 'web-epp.registry.net.za',
'port' => 3121,
'additional_contacts' => true
),
'net.za' => array(
'fqdn' => 'net-epp.registry.net.za',
'port' => 3121,
'additional_contacts' => true
),
);
if (!is_null($domain)) {
foreach ($tldservers as $tld => $data) {
if (preg_match("/$tld$/i", $domain)) {
return $data;
}
}
throw new Exception('SLD lookup failed to find: '.$domain);
} else { # defaults to co.za server.
return $tldservers['co.za'];
}
}
# Function to create internal COZA EPP request
function _cozaepp_Client() {
function _cozaepp_Client($domain=null) {
# Setup include dir
$include_path = ROOTDIR . '/modules/registrars/cozaepp';
set_include_path($include_path . PATH_SEPARATOR . get_include_path());
......@@ -1300,13 +1340,14 @@ function _cozaepp_Client() {
# Grab module parameters
$params = getregistrarconfigoptions('cozaepp');
# Set server address and port based on parsed domain name
$_server = _cozaepp_SldLookup($domain);
# Check if module parameters are sane
if (empty($params['Username']) || empty($params['Password'])) {
throw new Exception('System configuration error(1), please contact your provider');
}
if ($params['Server'] != 'regphase3.dnservices.co.za' && $params['Server'] != 'epp.coza.net.za') {
throw new Exception('System configuration error(2), please contact your provider');
}
# Create SSL context
$context = stream_context_create();
......@@ -1328,7 +1369,7 @@ function _cozaepp_Client() {
$client = new Net_EPP_Client();
# Connect
$res = $client->connect($params['Server'], $params['Port'], 10, $use_ssl, $context);
$res = $client->connect($_server['fqdn'], $_server['port'], 10, $use_ssl, $context);
# Perform login
$request = $client->request($xml = '
......@@ -1371,7 +1412,7 @@ function cozaepp_TransferSync($params) {
# Grab domain info
try {
$client = _cozaepp_Client();
$client = _cozaepp_Client($domain);
# Grab domain info
$request = $client->request($xml = '
<epp:epp xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:epp="urn:ietf:params:xml:ns:epp-1.0"
......@@ -1436,10 +1477,10 @@ function cozaepp_RecreateContact($params) {
$tld = $params["tld"];
$sld = $params["sld"];
$domain = strtolower("$sld.$tld");
# Get client instance
try {
$client = _cozaepp_Client();
$client = _cozaepp_Client($domain);
# Fetching contact details
$contact = _getContactDetails($domain, $client);
......@@ -1552,7 +1593,7 @@ function cozaepp_Sync($params) {
# Grab domain info
try {
$client = _cozaepp_Client();
$client = _cozaepp_Client($domain);
# Grab domain info
$request = $client->request($xml = '
<epp:epp xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:epp="urn:ietf:params:xml:ns:epp-1.0"
......@@ -1645,7 +1686,7 @@ function cozaepp_RequestDelete($params) {
# Grab domain info
try {
$client = _cozaepp_Client();
$client = _cozaepp_Client($domain);
# Grab domain info
$request = $client->request($xml = '
......@@ -1692,7 +1733,7 @@ function cozaepp_ApproveTransfer($params) {
# Grab domain info
try {
$client = _cozaepp_Client();
$client = _cozaepp_Client($domain);
# Grab domain info
$request = $client->request($xml = '
......@@ -1739,7 +1780,7 @@ function cozaepp_CancelTransferRequest($params) {
# Grab domain info
try {
$client = _cozaepp_Client();
$client = _cozaepp_Client($domain);
# Grab domain info
$request = $client->request($xml = '
......@@ -1786,7 +1827,7 @@ function cozaepp_RejectTransfer($params) {
# Grab domain info
try {
$client = _cozaepp_Client();
$client = _cozaepp_Client($domain);
# Grab domain info
$request = $client->request($xml = '
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment