minor changes
Adding compatibility for multiple records inside one PowerDNS RRSet
This commit is contained in:
parent
8d90b99d02
commit
b9aa3aacd2
10
config.php
10
config.php
|
@ -4,12 +4,10 @@ $config = array();
|
||||||
|
|
||||||
$config["db_host"] = "127.0.0.1";
|
$config["db_host"] = "127.0.0.1";
|
||||||
$config["db_port"] = "3306";
|
$config["db_port"] = "3306";
|
||||||
$config["db_username"] = "powerdnsapi";
|
$config["db_username"] = "pdns-api";
|
||||||
$config["db_password"] = "powerdnsapi";
|
$config["db_password"] = "pdns-api";
|
||||||
$config["db_database"] = "powerdnsapi";
|
$config["db_database"] = "pdns-api";
|
||||||
|
|
||||||
$config["base_uri"] = "http://localhost/pdns-api"
|
$config["base_uri"] = "http://localhost/pdns-api";
|
||||||
|
|
||||||
$config["debug"] = false;
|
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -90,6 +90,8 @@ app()->patch($API_PREFIX . "/servers/{server_id}/zones/{zone_id}", function ($se
|
||||||
|
|
||||||
$records = getRecordsFromDomainNameAndZoneRequestAndKeyHelpDnsEntry($keyHelpDomainName, json_decode($input), $keyHelpDnsEntry);
|
$records = getRecordsFromDomainNameAndZoneRequestAndKeyHelpDnsEntry($keyHelpDomainName, json_decode($input), $keyHelpDnsEntry);
|
||||||
|
|
||||||
|
//response()->exit(json_encode($records), 200);
|
||||||
|
|
||||||
keyHelp_putDns($server["hostname"], $server["api_key"], $domainId, $records);
|
keyHelp_putDns($server["hostname"], $server["api_key"], $domainId, $records);
|
||||||
|
|
||||||
response()->plain("", 204);
|
response()->plain("", 204);
|
||||||
|
|
|
@ -56,6 +56,10 @@ function getRecordsFromDomainNameAndZoneRequestAndKeyHelpDnsEntry($domainName, $
|
||||||
if(count($keyHelpRecords) > 0) {
|
if(count($keyHelpRecords) > 0) {
|
||||||
for ($i = 0; $i < count($keyHelpRecords); $i++) {
|
for ($i = 0; $i < count($keyHelpRecords); $i++) {
|
||||||
$currentKeyHelpRecord = $keyHelpRecords[$i];
|
$currentKeyHelpRecord = $keyHelpRecords[$i];
|
||||||
|
|
||||||
|
if ($currentKeyHelpRecord->type == "SOA") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$changedRecordIndex = getRecordIndexForNameAndType($changedRecords, $currentKeyHelpRecord->name, $currentKeyHelpRecord->type);
|
$changedRecordIndex = getRecordIndexForNameAndType($changedRecords, $currentKeyHelpRecord->name, $currentKeyHelpRecord->type);
|
||||||
|
|
||||||
|
@ -69,6 +73,10 @@ function getRecordsFromDomainNameAndZoneRequestAndKeyHelpDnsEntry($domainName, $
|
||||||
$newRecord->ttl = $changedRecord->ttl;
|
$newRecord->ttl = $changedRecord->ttl;
|
||||||
$newRecord->type = $changedRecord->type;
|
$newRecord->type = $changedRecord->type;
|
||||||
$newRecord->value = $changedRecord->records[$x]->content;
|
$newRecord->value = $changedRecord->records[$x]->content;
|
||||||
|
|
||||||
|
if ($newRecord->host == "") {
|
||||||
|
$newRecord->host = "@";
|
||||||
|
}
|
||||||
|
|
||||||
$output->records->other[] = $newRecord;
|
$output->records->other[] = $newRecord;
|
||||||
}
|
}
|
||||||
|
@ -82,6 +90,10 @@ function getRecordsFromDomainNameAndZoneRequestAndKeyHelpDnsEntry($domainName, $
|
||||||
$newRecord->ttl = $currentKeyHelpRecord->ttl;
|
$newRecord->ttl = $currentKeyHelpRecord->ttl;
|
||||||
$newRecord->type = $currentKeyHelpRecord->type;
|
$newRecord->type = $currentKeyHelpRecord->type;
|
||||||
$newRecord->value = $currentKeyHelpRecord->records[$x]->content;
|
$newRecord->value = $currentKeyHelpRecord->records[$x]->content;
|
||||||
|
|
||||||
|
if ($newRecord->host == "") {
|
||||||
|
$newRecord->host = "@";
|
||||||
|
}
|
||||||
|
|
||||||
$output->records->other[] = $newRecord;
|
$output->records->other[] = $newRecord;
|
||||||
}
|
}
|
||||||
|
@ -97,6 +109,10 @@ function getRecordsFromDomainNameAndZoneRequestAndKeyHelpDnsEntry($domainName, $
|
||||||
$newRecord->ttl = $changedRecord->ttl;
|
$newRecord->ttl = $changedRecord->ttl;
|
||||||
$newRecord->type = $changedRecord->type;
|
$newRecord->type = $changedRecord->type;
|
||||||
$newRecord->value = $changedRecord->records[$x]->content;
|
$newRecord->value = $changedRecord->records[$x]->content;
|
||||||
|
|
||||||
|
if ($newRecord->host == "") {
|
||||||
|
$newRecord->host = "@";
|
||||||
|
}
|
||||||
|
|
||||||
$output->records->other[] = $newRecord;
|
$output->records->other[] = $newRecord;
|
||||||
}
|
}
|
||||||
|
|
16
index.php
16
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"]);
|
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();
|
app()->run();
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -58,7 +58,10 @@ class RRSet {
|
||||||
|
|
||||||
$output->name = $zoneRequestRRSet->name;
|
$output->name = $zoneRequestRRSet->name;
|
||||||
$output->type = $zoneRequestRRSet->type;
|
$output->type = $zoneRequestRRSet->type;
|
||||||
$output->ttl = $zoneRequestRRSet->ttl;
|
|
||||||
|
if (property_exists($zoneRequestRRSet, "ttl")) {
|
||||||
|
$output->ttl = $zoneRequestRRSet->ttl;
|
||||||
|
}
|
||||||
|
|
||||||
if (property_exists($zoneRequestRRSet, "changetype")) {
|
if (property_exists($zoneRequestRRSet, "changetype")) {
|
||||||
$output->changetype = $zoneRequestRRSet->changetype;
|
$output->changetype = $zoneRequestRRSet->changetype;
|
||||||
|
|
Loading…
Reference in a new issue