aboutsummaryrefslogtreecommitdiffstats
path: root/config/bind/bind.inc
diff options
context:
space:
mode:
authorcrocomo <crocomo@btree.de>2014-03-20 12:51:21 +0100
committercrocomo <crocomo@btree.de>2014-03-20 12:51:21 +0100
commit2dcbc82e0e71ee9944ba32e3c34fa8e4af200d25 (patch)
treee605d2dcde49f00429fc5d309aa1361bfa93eb8c /config/bind/bind.inc
parent79719c58b2d433d5f151eb2a7d9766a8cc74088d (diff)
downloadpfsense-packages-2dcbc82e0e71ee9944ba32e3c34fa8e4af200d25.tar.gz
pfsense-packages-2dcbc82e0e71ee9944ba32e3c34fa8e4af200d25.tar.bz2
pfsense-packages-2dcbc82e0e71ee9944ba32e3c34fa8e4af200d25.zip
bind
Diffstat (limited to 'config/bind/bind.inc')
-rw-r--r--config/bind/bind.inc67
1 files changed, 39 insertions, 28 deletions
diff --git a/config/bind/bind.inc b/config/bind/bind.inc
index 156e9eb8..17d171d1 100644
--- a/config/bind/bind.inc
+++ b/config/bind/bind.inc
@@ -445,35 +445,46 @@ EOD;
$zone_conf .= "$hostname \t IN $hosttype $hostvalue \t$hostdst\n";
}
+
+ # Register DHCP static mappings
if (($zone[regdhcpstatic] == 'on') && is_array($config['dhcpd'])) {
- foreach ($config['dhcpd'] as $dhcpif => $dhcpifconf)
- if(is_array($dhcpifconf['staticmap']) && isset($dhcpifconf['enable']))
- foreach ($dhcpifconf['staticmap'] as $host)
- if ($host['ipaddr'] && $host['hostname']) {
- if($zonereverso == "on") {
- $hostdomain = $dhcpifconf['domain'];
- if(strlen($hostdomain) == 0) {
- $hostdomain = $config['system']['domain'];
- }
- if(strlen($hostdomain) != 0) {
- $hostdomain .= '.';
- }
- $zoneparts = array_reverse(explode('.',$zonename));
- $addressparts = explode('.',$host['ipaddr']);
- $addressstart = 0;
- while($addressstart < count($zoneparts) && $addressstart < count($addressparts) && $zoneparts[$addressstart] == $addressparts[$addressstart]) {
- $addressstart++;
- }
- $shortaddress='';
- for($addresspointer = count($addressparts)-1; $addresspointer >= $addressstart; $addresspointer--) {
- $shortaddress .= (strlen($shortaddress) > 0 ? '.' : '') . $addressparts[$addresspointer];
- }
- $zone_conf .= "{$shortaddress}\tIN PTR\t{$host['hostname']}.{$hostdomain}\n";
- } else {
- $zone_conf .= "{$host['hostname']}\tIN A\t{$host['ipaddr']}\n";
- }
- }
- }
+ $zoneparts = array_reverse(explode('.',$zonename));
+ foreach ($config['dhcpd'] as $dhcpif => $dhcpifconf) {
+ if (!isset($dhcpifconf['enable']) || !is_array($dhcpifconf['staticmap'])) {
+ continue;
+ }
+ foreach ($dhcpifconf['staticmap'] as $host) {
+ if (is_domain($host['domain'])) {
+ $domain = $host['domain'];
+ } elseif (is_domain($dhcpifconf['domain'])) {
+ $domain = $dhcpifconf['domain'];
+ } elseif (is_domain($config['system']['domain'])) {
+ $domain = $config['system']['domain'];
+ } else {
+ continue;
+ }
+ if (!is_hostname($host['hostname']) || !is_ipaddr($host['ipaddr'])) {
+ continue;
+ }
+ if ($zonereverso == "on") {
+ $parts = explode('.',$host['ipaddr']);
+ $intersect = array_intersect_assoc($parts,$zoneparts);
+ if (count($zoneparts) == count($intersect)) {
+ $diff = array_diff_assoc($parts,$zoneparts);
+ $shortaddr = implode('.',array_reverse($diff));
+ $zone_conf .= "{$shortaddr}\tIN PTR\t{$host['hostname']}.{$domain}.\n";
+ }
+ } else {
+ $parts = array_reverse(explode('.',$domain));
+ $diff = array_diff_assoc($parts,$zoneparts);
+ if (count($diff) == 0) {
+ $zone_conf .= "{$host['hostname']}\tIN A\t{$host['ipaddr']}\n";
+ }
+ }
+ }
+ }
+ }
+
if ($zone['customzonerecords']!=""){
$zone_conf .= "\n\n;\n;custom zone records\n;\n".base64_decode($zone['customzonerecords'])."\n";
}