aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorMarcello Coutinho <marcellocoutinho@gmail.com>2013-10-11 20:03:41 -0300
committerMarcello Coutinho <marcellocoutinho@gmail.com>2013-10-11 20:03:41 -0300
commit7ce2a27b33fefac065b3e890df9f304fba881e99 (patch)
tree03ed4a6c3752955dd0601c22973104d5f7933091 /config
parent8aa33410f80493930b33dad9e7f61742b3e0c72f (diff)
downloadpfsense-packages-7ce2a27b33fefac065b3e890df9f304fba881e99.tar.gz
pfsense-packages-7ce2a27b33fefac065b3e890df9f304fba881e99.tar.bz2
pfsense-packages-7ce2a27b33fefac065b3e890df9f304fba881e99.zip
bind - bump version and add field validation for zone tab
Diffstat (limited to 'config')
-rw-r--r--config/bind/bind.inc34
-rw-r--r--config/bind/bind_zones.xml52
2 files changed, 59 insertions, 27 deletions
diff --git a/config/bind/bind.inc b/config/bind/bind.inc
index 0eddda73..30828927 100644
--- a/config/bind/bind.inc
+++ b/config/bind/bind.inc
@@ -47,6 +47,29 @@ else
define('CHROOT_LOCALBASE','/conf/named');
+function bind_zone_validate($post, $input_errors){
+ if ($_POST['type']=='reverso'){
+ if( $_POST['nameserver'] == "")
+ $input_errors[] = 'The field \'Name Server\' is required';
+ }
+ if (key_exists("mail",$_POST))
+ $_POST['mail']=preg_replace("/@/",".",$post['mail']);
+ for ($i=0;$i < count($_POST);$i++){
+ if (key_exists("hostname$i",$_POST)){
+ if (preg_match("/(MX|NS)/",$_POST["hosttype$i"]))
+ $_POST["hostname$i"]="";
+ if (!preg_match("/(MX|NS)/",$_POST["hosttype$i"]) && $_POST["hostname$i"]=="")
+ $input_errors[] = 'Record cannot be empty for '.$_POST["hosttype$i"].' type ';
+ if ($_POST["hosttype$i"]=="MX" && $_POST["hostvalue$i"]=="")
+ $_POST["hostvalue$i"]="10";
+ if ($_POST["hosttype$i"]!="MX" && $_POST["hostvalue$i"]!="")
+ $_POST["hostvalue$i"]="";
+ if ($_POST["hostdst$i"]=="")
+ $input_errors[] = 'Alias or IP address cannot be empty.';
+ }
+ }
+}
+
function bind_sync(){
global $config;
@@ -68,8 +91,9 @@ $bind_conf .= <<<EOD
directory "/etc/namedb";
pid-file "/var/run/named/pid";
statistics-file "/var/log/named.stats";
+ max-cache-size {$ram_limit};
+ query-source address * port 53;
- max-cache-size $ram_limit;\n
EOD;
// check response rate limit option
//https://kb.isc.org/article/AA-01000/0/A-Quick-Introduction-to-Response-Rate-Limiting.html
@@ -273,6 +297,7 @@ EOD;
$zoneallowtransfer = str_replace(',','; ',$zone['allowtransfer']);
$zone_conf = "\$TTL $zonetll\n;\n";
$zone_conf .= ";\tDatabase file {$zonename}.DB for {$zonename} zone.\n";
+ $zone_conf .= ";\tDo not edit this file!!!\n";
$zone_conf .= ";\tZone version {$zoneserial}\n;\n";
if($zonereverso == "on")
$zone_conf .= "@\t IN SOA $zonenameserver. \t $zonemail. (\n";
@@ -283,14 +308,15 @@ EOD;
$zone_conf .= "\t\t$zonerefresh ; refresh\n";
$zone_conf .= "\t\t$zoneretry ; retry\n";
$zone_conf .= "\t\t$zoneexpire ; expire\n";
- $zone_conf .= "\t\t$zoneminimum)\n\n";
+ $zone_conf .= "\t\t$zoneminimum ; default_ttl\n\t\t)\n\n";
$zone_conf .= ";\n; Zone Records\n;\n";
if($zonereverso == "on")
$zone_conf .= "\t IN NS \t\t$zonenameserver.\n";
else{
- $zone_conf .= "@ \t IN NS \t\t$zonenameserver.\n";
- $zone_conf .= "@ \t IN A \t\t$zoneipns\n";
+ $zone_conf .= "@ \t IN NS \t\t$zonenameserver.\n";
+ if ($zoneipns !="")
+ $zone_conf .= "@ \t IN A \t\t$zoneipns\n";
}
for ($y=0; $y<sizeof($zone['row']); $y++)
{
diff --git a/config/bind/bind_zones.xml b/config/bind/bind_zones.xml
index 810fef89..93dffde0 100644
--- a/config/bind/bind_zones.xml
+++ b/config/bind/bind_zones.xml
@@ -82,11 +82,11 @@
<configpath>['installedpackages']['bindzone']['config']</configpath>
<adddeleteeditpagefields>
<columnitem>
- <fielddescr>Zones Name</fielddescr>
+ <fielddescr>Zone Name</fielddescr>
<fieldname>name</fieldname>
</columnitem>
<columnitem>
- <fielddescr>Zonas Type</fielddescr>
+ <fielddescr>Zone Type</fielddescr>
<fieldname>type</fieldname>
</columnitem>
<columnitem>
@@ -106,16 +106,16 @@
<fieldname>temp01</fieldname>
</field>
<field>
- <fielddescr>Zone Name:</fielddescr>
+ <fielddescr>Zone Name</fielddescr>
<fieldname>name</fieldname>
- <description>Enter the name for zone (ex:exemple.com.br)</description>
+ <description>Enter the name for zone (ex:mydomain.com)</description>
<type>input</type>
- <required/>
+ <required/>
</field>
<field>
- <fielddescr>Zonas Type</fielddescr>
+ <fielddescr>Zone Type</fielddescr>
<fieldname>type</fieldname>
- <description>Select the type that zone to Master Primary DNS, Secondary DNS to select Slave.</description>
+ <description>Select zone type</description>
<type>select</type>
<options>
<option>
@@ -142,9 +142,9 @@
<source_value>name</source_value>
</field>
<field>
- <fielddescr>Zone Reverse</fielddescr>
+ <fielddescr>Reverse Zone</fielddescr>
<fieldname>reverso</fieldname>
- <description>Enable this if the zone is reverse.</description>
+ <description>Enable if this is a reverse zone.</description>
<type>checkbox</type>
</field>
<field>
@@ -188,19 +188,19 @@
<field>
<fielddescr>Name Server</fielddescr>
<fieldname>nameserver</fieldname>
- <description>Enter ns.example.com is a nameserver for example.com</description>
+ <description>Enter nameserver for this zone</description>
<type>input</type>
</field>
<field>
- <fielddescr>IP Name Server</fielddescr>
+ <fielddescr>Base Domain ip</fielddescr>
<fieldname>ipns</fieldname>
- <description>Enter address ip for nameserver</description>
+ <description>Enter ip address for base domain lookup. Ex: nslookup mydomain.com</description>
<type>input</type>
</field>
<field>
<fielddescr>Mail Admin Zone</fielddescr>
<fieldname>mail</fieldname>
- <description>Enter mail admin zone, is . not @</description>
+ <description>Enter mail admin zone.</description>
<type>input</type>
</field>
<field>
@@ -272,23 +272,28 @@
</field>
<field>
<type>listtopic</type>
- <name>Hosts Configuration Zone Domain</name>
+ <name>Zone Domain records</name>
<fieldname>temp02</fieldname>
</field>
<field>
- <fielddescr>Enter the desired host, "Host Name" is the name of the Host: www or pop, "Host Type" simple kind host, "Value" in case the MX priority, "CNAME or IP address" is the destination host.</fielddescr>
+ <fielddescr>Enter Domain records.</fielddescr>
+ <description><![CDATA[<b>"Record"</b> is the name or last octec of ip. Sample: www or pop<br>
+ <b>"Type"</b> is the type of the record Sample: A CNAME MX NS<br>
+ <b>"Priority"</b> in used only in mx records to define its priority<br>
+ <b>"Alias or IP address"</b> is the destination host or ip address.<br><br>
+ You can order elements on this list with drag and drop between columns.]]></description>
<fieldname>none</fieldname>
<type>rowhelper</type>
<rowhelper>
<rowhelperfield>
- <fielddescr>Host Name</fielddescr>
+ <fielddescr>Record</fielddescr>
<fieldname>hostname</fieldname>
<description>Enter the Host Name (ex: www)</description>
<type>input</type>
- <size>20</size>
+ <size>10</size>
</rowhelperfield>
<rowhelperfield>
- <fielddescr>Host Type</fielddescr>
+ <fielddescr>Type</fielddescr>
<fieldname>hosttype</fieldname>
<description>Select Type Host</description>
<type>select</type>
@@ -306,18 +311,18 @@
</options>
</rowhelperfield>
<rowhelperfield>
- <fielddescr>Value</fielddescr>
+ <fielddescr>Priority</fielddescr>
<fieldname>hostvalue</fieldname>
<description>MX 10 or 20</description>
<type>input</type>
- <size>1</size>
+ <size>3</size>
</rowhelperfield>
<rowhelperfield>
- <fielddescr>Ip Address or CNAME destination</fielddescr>
+ <fielddescr>Alias or IP address</fielddescr>
<fieldname>hostdst</fieldname>
<description>Enter the IP address or CNAME destination for Domain (ex: 10.31.11.1 or mail.example.com)</description>
<type>input</type>
- <size>20</size>
+ <size>35</size>
</rowhelperfield>
</rowhelper>
</field>
@@ -331,7 +336,8 @@
<custom_php_command_before_form>
</custom_php_command_before_form>
<custom_php_validation_command>
- $_POST['serial']=(date("U")+ 1000000000);
+ $_POST['serial']=(date("U")+ 1000000000);
+ bind_zone_validate($_POST, &amp;$input_errors);
</custom_php_validation_command>
<custom_delete_php_command>
bind_sync();