diff --git a/config.php b/config.php index ca0e2c8..357f848 100644 --- a/config.php +++ b/config.php @@ -4,12 +4,10 @@ $config = array(); $config["db_host"] = "127.0.0.1"; $config["db_port"] = "3306"; -$config["db_username"] = "powerdnsapi"; -$config["db_password"] = "powerdnsapi"; -$config["db_database"] = "powerdnsapi"; +$config["db_username"] = "pdns-api"; +$config["db_password"] = "pdns-api"; +$config["db_database"] = "pdns-api"; -$config["base_uri"] = "http://localhost/pdns-api" - -$config["debug"] = false; +$config["base_uri"] = "http://localhost/pdns-api"; ?> \ No newline at end of file diff --git a/endpoints/01_Zones.php b/endpoints/01_Zones.php index aed0798..aeb8fe0 100644 --- a/endpoints/01_Zones.php +++ b/endpoints/01_Zones.php @@ -90,6 +90,8 @@ app()->patch($API_PREFIX . "/servers/{server_id}/zones/{zone_id}", function ($se $records = getRecordsFromDomainNameAndZoneRequestAndKeyHelpDnsEntry($keyHelpDomainName, json_decode($input), $keyHelpDnsEntry); + //response()->exit(json_encode($records), 200); + keyHelp_putDns($server["hostname"], $server["api_key"], $domainId, $records); response()->plain("", 204); diff --git a/helpers/ZoneHelper.php b/helpers/ZoneHelper.php index 3a48d77..618b9ea 100644 --- a/helpers/ZoneHelper.php +++ b/helpers/ZoneHelper.php @@ -56,6 +56,10 @@ function getRecordsFromDomainNameAndZoneRequestAndKeyHelpDnsEntry($domainName, $ if(count($keyHelpRecords) > 0) { for ($i = 0; $i < count($keyHelpRecords); $i++) { $currentKeyHelpRecord = $keyHelpRecords[$i]; + + if ($currentKeyHelpRecord->type == "SOA") { + continue; + } $changedRecordIndex = getRecordIndexForNameAndType($changedRecords, $currentKeyHelpRecord->name, $currentKeyHelpRecord->type); @@ -69,6 +73,10 @@ function getRecordsFromDomainNameAndZoneRequestAndKeyHelpDnsEntry($domainName, $ $newRecord->ttl = $changedRecord->ttl; $newRecord->type = $changedRecord->type; $newRecord->value = $changedRecord->records[$x]->content; + + if ($newRecord->host == "") { + $newRecord->host = "@"; + } $output->records->other[] = $newRecord; } @@ -82,6 +90,10 @@ function getRecordsFromDomainNameAndZoneRequestAndKeyHelpDnsEntry($domainName, $ $newRecord->ttl = $currentKeyHelpRecord->ttl; $newRecord->type = $currentKeyHelpRecord->type; $newRecord->value = $currentKeyHelpRecord->records[$x]->content; + + if ($newRecord->host == "") { + $newRecord->host = "@"; + } $output->records->other[] = $newRecord; } @@ -97,6 +109,10 @@ function getRecordsFromDomainNameAndZoneRequestAndKeyHelpDnsEntry($domainName, $ $newRecord->ttl = $changedRecord->ttl; $newRecord->type = $changedRecord->type; $newRecord->value = $changedRecord->records[$x]->content; + + if ($newRecord->host == "") { + $newRecord->host = "@"; + } $output->records->other[] = $newRecord; } diff --git a/index.php b/index.php index 58317cc..00d540e 100644 --- a/index.php +++ b/index.php @@ -12,22 +12,6 @@ require __DIR__ . "/endpoints/autoload.php"; db()->connect($config["db_host"] . ":" . $config["db_port"], $config["db_database"], $config["db_username"], $config["db_password"]); -if ($config["debug"]) { - app()->get($API_PREFIX . "/debug", function () { - response()->json( - dns_get_record("oswald-cloud.de", DNS_SOA) - //keyHelp_getDomains("lithium.server.ossinet.de", "L9r9MbEN.eswinlGhxQILroLhYkwWWdLKfKZ1cMSjHIGnOycN9yBDm9sf8PehutkHKVYj4W591Kqoli2Q4V0tI1wkLYvn1PRDONgmv4rINsI9FJucZtOeOEDlVmxiaqAU") - ); - }); - - app()->patch($API_PREFIX . "/debug", function () { - response()->json( - Leaf\Http\Headers::all() - //keyHelp_getDomains("lithium.server.ossinet.de", "L9r9MbEN.eswinlGhxQILroLhYkwWWdLKfKZ1cMSjHIGnOycN9yBDm9sf8PehutkHKVYj4W591Kqoli2Q4V0tI1wkLYvn1PRDONgmv4rINsI9FJucZtOeOEDlVmxiaqAU") - ); - }); -} - app()->run(); ?> \ No newline at end of file diff --git a/models/RRSet.php b/models/RRSet.php index 201f2e5..9027cfa 100644 --- a/models/RRSet.php +++ b/models/RRSet.php @@ -58,7 +58,10 @@ class RRSet { $output->name = $zoneRequestRRSet->name; $output->type = $zoneRequestRRSet->type; - $output->ttl = $zoneRequestRRSet->ttl; + + if (property_exists($zoneRequestRRSet, "ttl")) { + $output->ttl = $zoneRequestRRSet->ttl; + } if (property_exists($zoneRequestRRSet, "changetype")) { $output->changetype = $zoneRequestRRSet->changetype;