various fixes for dns with froxlor-hostname
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -16,22 +16,33 @@
|
||||
*/
|
||||
function createDomainZone($domain_id, $froxlorhostname = false)
|
||||
{
|
||||
if (!$froxlorhostname)
|
||||
{
|
||||
// get domain-name
|
||||
$dom_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_DOMAINS . "` WHERE id = :did");
|
||||
$domain = Database::pexecute_first($dom_stmt, array(
|
||||
'did' => $domain_id
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
$domain = $domain_id;
|
||||
}
|
||||
|
||||
if ($domain['isbinddomain'] != '1') {
|
||||
return;
|
||||
}
|
||||
|
||||
$dom_entries = array();
|
||||
if (!$froxlorhostname)
|
||||
{
|
||||
// select all entries
|
||||
$sel_stmt = Database::prepare("SELECT * FROM `" . TABLE_DOMAIN_DNS . "` WHERE domain_id = :did ORDER BY id ASC");
|
||||
Database::pexecute($sel_stmt, array(
|
||||
'did' => $domain_id
|
||||
));
|
||||
$dom_entries = $sel_stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
// check for required records
|
||||
$required_entries = array();
|
||||
@@ -52,6 +63,8 @@ function createDomainZone($domain_id, $froxlorhostname = false)
|
||||
addRequiredEntry('www', 'AAAA', $required_entries);
|
||||
}
|
||||
|
||||
if (!$froxlorhostname)
|
||||
{
|
||||
// additional required records for subdomains
|
||||
$subdomains_stmt = Database::prepare("
|
||||
SELECT `domain` FROM `" . TABLE_PANEL_DOMAINS . "`
|
||||
@@ -90,6 +103,7 @@ function createDomainZone($domain_id, $froxlorhostname = false)
|
||||
// Add NS entry for subdomain-records of "main-but-subdomain-to"-domains, they get their own Zone
|
||||
addRequiredEntry(str_replace('.' . $domain['domain'], '', $mainbutsubtodomain['domain']), 'NS', $required_entries);
|
||||
}
|
||||
}
|
||||
|
||||
// additional required records for SPF and DKIM if activated
|
||||
if ($domain['isemaildomain'] == '1') {
|
||||
@@ -136,6 +150,7 @@ function createDomainZone($domain_id, $froxlorhostname = false)
|
||||
$result_ip_stmt = Database::prepare("
|
||||
SELECT `ip` FROM `" . TABLE_PANEL_IPSANDPORTS . "` GROUP BY `ip`
|
||||
");
|
||||
Database::pexecute($result_ip_stmt);
|
||||
} else {
|
||||
$result_ip_stmt = Database::prepare("
|
||||
SELECT `p`.`ip` AS `ip`
|
||||
@@ -143,10 +158,10 @@ function createDomainZone($domain_id, $froxlorhostname = false)
|
||||
WHERE `di`.`id_domain` = :domainid AND `p`.`id` = `di`.`id_ipandports`
|
||||
GROUP BY `p`.`ip`;
|
||||
");
|
||||
}
|
||||
Database::pexecute($result_ip_stmt, array(
|
||||
'domainid' => $domain_id
|
||||
));
|
||||
}
|
||||
$all_ips = $result_ip_stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
foreach ($all_ips as $ip) {
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
<?php
|
||||
|
||||
/***
|
||||
* Class DnsBase
|
||||
*
|
||||
* Base class for all DNS server configs
|
||||
*
|
||||
*/
|
||||
abstract class DnsBase {
|
||||
abstract class DnsBase
|
||||
{
|
||||
|
||||
protected $_logger = false;
|
||||
|
||||
@@ -81,6 +83,7 @@ abstract class DnsBase {
|
||||
$hostname_arr = array(
|
||||
'id' => 'none',
|
||||
'domain' => Settings::Get('system.hostname'),
|
||||
'isbinddomain' => '1',
|
||||
'isemaildomain' => Settings::Get('system.dns_createmailentry'),
|
||||
'customerid' => 'none',
|
||||
'loginname' => 'froxlor.panel',
|
||||
@@ -181,5 +184,4 @@ abstract class DnsBase {
|
||||
$this->_logger->logAction(CRON_ACTION, LOG_INFO, 'Dkim-milter reloaded');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -46,7 +46,7 @@ class bind extends DnsBase
|
||||
}
|
||||
// create zone-file
|
||||
$this->_logger->logAction(CRON_ACTION, LOG_DEBUG, 'Generating dns zone for ' . $domain['domain']);
|
||||
$zone = createDomainZone($domain['id'], $isFroxlorHostname);
|
||||
$zone = createDomainZone(($domain['id'] == 'none') ? $domain : $domain['id'], $isFroxlorHostname);
|
||||
$zonefile = (string)$zone;
|
||||
$domain['zonefile'] = 'domains/' . $domain['domain'] . '.zone';
|
||||
$zonefile_name = makeCorrectFile(Settings::Get('system.bindconf_directory') . '/' . $domain['zonefile']);
|
||||
|
||||
@@ -44,7 +44,7 @@ class pdns extends DnsBase
|
||||
}
|
||||
// create zone-file
|
||||
$this->_logger->logAction(CRON_ACTION, LOG_DEBUG, 'Generating dns zone for ' . $domain['domain']);
|
||||
$zone = createDomainZone($domain['id'], $isFroxlorHostname);
|
||||
$zone = createDomainZone(($domain['id'] == 'none') ? $domain : $domain['id'], $isFroxlorHostname);
|
||||
|
||||
$dom_id = $this->_insertZone($zone->origin, $zone->serial);
|
||||
$this->_insertRecords($dom_id, $zone->records);
|
||||
|
||||
Reference in New Issue
Block a user