From caf135854ec7df07301512e972e3bc637e3abe9e Mon Sep 17 00:00:00 2001 From: Marcello Coutinho Date: Wed, 16 Oct 2013 22:40:12 -0300 Subject: bind - show result file on zone tab and fix slave zone check --- config/bind/bind.inc | 193 +++++++++++++++++++++++++-------------------- config/bind/bind_zones.xml | 20 ++++- 2 files changed, 127 insertions(+), 86 deletions(-) (limited to 'config') diff --git a/config/bind/bind.inc b/config/bind/bind.inc index 67677972..44ec0ed1 100644 --- a/config/bind/bind.inc +++ b/config/bind/bind.inc @@ -48,26 +48,36 @@ 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.'; - } + + if ($_POST['type']=='slave'){ + if( $_POST['slaveip'] == "") + $input_errors[] = 'The field \'Master Zone IP\' is required for slave zones.'; } + else{ + if($_POST['nameserver']=='') + $input_errors[] = 'The field \'Name server\' is required for master zones.'; + for ($i=0;$i < count($_POST);$i++){ + if (key_exists("hostname$i",$_POST)){ + if ($_POST['reverso']=="on"){ + $_POST["hostvalue$i"]=""; + if (!preg_match("/(PTR|NS)/",$_POST["hosttype$i"])) + $input_errors[] = 'On reverse zones, valid record types are NS or PTR'; + } + 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(){ @@ -75,7 +85,7 @@ function bind_zone_validate($post, $input_errors){ global $config; conf_mount_rw(); - $bind = $config["installedpackages"]["bind"]["config"][0]; + $bind = $config["installedpackages"]["bind"]["config"][0]; $bind_enable = $bind['enable_bind']; $bind_forwarder = $bind['bind_forwarder']; $forwarder_ips = $bind['bind_forwarder_ips']; @@ -84,8 +94,8 @@ function bind_zone_validate($post, $input_errors){ $bind_notify = $bind['bind_notify']; $custom_options = base64_decode($bind['bind_custom_options']); $bind_logging = $bind['bind_logging']; - $bind_conf ="#Bind pfsense configuration\n"; - $bind_conf .="#Do not edit this file!!!\n"; + $bind_conf ="#Bind pfsense configuration\n"; + $bind_conf .="#Do not edit this file!!!\n"; $bind_conf .= <<"any","description"=>"Default Access list","row" => array("value"=> "","description"=>"")); - write_config(); + write_config("Create Default bind acl 'Any'"); } $bindacls = $config["installedpackages"]["bindacls"]["config"]; for ($i=0; $i 0){ + write_config("save result config file for zone on xml"); + } + $bind_conf .= "};\n"; } $dirs=array("/etc/namedb","/var/run/named","/var/dump","/var/log","/var/stats"); foreach ($dirs as $dir){ @@ -403,7 +428,7 @@ function bind_print_javascript_type_zone(){ } function bind_print_javascript_type_zone2(){ - print("\n"); + print("\n"); } function bind_write_rcfile() { diff --git a/config/bind/bind_zones.xml b/config/bind/bind_zones.xml index 93dffde0..11cfb0e2 100644 --- a/config/bind/bind_zones.xml +++ b/config/bind/bind_zones.xml @@ -108,7 +108,9 @@ Zone Name name - Enter the name for zone (ex:mydomain.com) + + For reverse zones, include zone ip in reverse order or following your provider instructions.(Ex: 1.168.192)
+ IN-ADDR.ARPA will be automaticaly included on conf files when reveser zone option is checked.]]>
input
@@ -169,7 +171,7 @@ temp04 - IP Master Zone + Master Zone IP slaveip If zone is slave, enter the IP address of the master DNS zone. input @@ -326,6 +328,20 @@ + + listtopic + Zone config file + temp03 + + + Resulting config file + resultconfig + Resulting bind config file for this zone. + textarea + 75 + 15 + base64 + bind_print_javascript_type_zone2(); -- cgit v1.2.3