Commit 936dead8 authored by Franco Fichtner's avatar Franco Fichtner

dns: some style and sanity for dnydnses and dnsupdates gears

parent 97cac62f
......@@ -70,27 +70,30 @@ if (function_exists("display_error_form") && !isset($config['system']['webgui'][
strcasecmp($http_host, $config['system']['hostname']) == 0)
$found_host = true;
if(isset($config['dyndnses']['dyndns']) && is_array($config['dyndnses']['dyndns']) && !$found_host)
if (isset($config['dyndnses']['dyndns']) && !$found_host)
foreach($config['dyndnses']['dyndns'] as $dyndns)
if(strcasecmp($dyndns['host'], $http_host) == 0) {
$found_host = true;
break;
}
if(isset($config['dnsupdates']['dnsupdate']) && is_array($config['dnsupdates']['dnsupdate']) && !$found_host)
foreach($config['dnsupdates']['dnsupdate'] as $rfc2136)
if(strcasecmp($rfc2136['host'], $http_host) == 0) {
if (isset($config['dnsupdates']['dnsupdate']) && !$found_host) {
foreach ($config['dnsupdates']['dnsupdate'] as $rfc2136) {
if (strcasecmp($rfc2136['host'], $http_host) == 0) {
$found_host = true;
break;
}
}
}
if(!empty($config['system']['webgui']['althostnames']) && !$found_host) {
if (!empty($config['system']['webgui']['althostnames']) && !$found_host) {
$althosts = explode(" ", $config['system']['webgui']['althostnames']);
foreach ($althosts as $ah)
if(strcasecmp($ah, $http_host) == 0 or strcasecmp($ah, $_SERVER['SERVER_ADDR']) == 0) {
foreach ($althosts as $ah) {
if (strcasecmp($ah, $http_host) == 0 or strcasecmp($ah, $_SERVER['SERVER_ADDR']) == 0) {
$found_host = true;
break;
}
}
}
if($found_host == false) {
......@@ -122,7 +125,7 @@ if(function_exists("display_error_form") && !isset($config['system']['webgui']['
|| strcasecmp($referrer_host, $config['system']['hostname']) == 0)
$found_host = true;
if(!empty($config['system']['webgui']['althostnames']) && !$found_host) {
if (!empty($config['system']['webgui']['althostnames']) && !$found_host) {
$althosts = explode(" ", $config['system']['webgui']['althostnames']);
foreach ($althosts as $ah) {
if(strcasecmp($referrer_host, $ah) == 0) {
......@@ -132,19 +135,23 @@ if(function_exists("display_error_form") && !isset($config['system']['webgui']['
}
}
if(isset($config['dyndnses']['dyndns']) && is_array($config['dyndnses']['dyndns']) && !$found_host)
foreach($config['dyndnses']['dyndns'] as $dyndns)
if(strcasecmp($dyndns['host'], $referrer_host) == 0) {
if (isset($config['dyndnses']['dyndns']) && !$found_host) {
foreach ($config['dyndnses']['dyndns'] as $dyndns) {
if (strcasecmp($dyndns['host'], $referrer_host) == 0) {
$found_host = true;
break;
}
}
}
if(isset($config['dnsupdates']['dnsupdate']) && is_array($config['dnsupdates']['dnsupdate']) && !$found_host)
foreach($config['dnsupdates']['dnsupdate'] as $rfc2136)
if(strcasecmp($rfc2136['host'], $referrer_host) == 0) {
if (isset($config['dnsupdates']['dnsupdate']) && !$found_host) {
foreach ($config['dnsupdates']['dnsupdate'] as $rfc2136) {
if (strcasecmp($rfc2136['host'], $referrer_host) == 0) {
$found_host = true;
break;
}
}
}
if(!$found_host) {
$found_host = isAuthLocalIP($referrer_host);
......
......@@ -904,16 +904,19 @@ function openvpn_client_export_find_port_forwards($targetip, $targetport, $targe
return $destinations;
}
function openvpn_client_export_find_hostname($interface) {
function openvpn_client_export_find_hostname($interface)
{
global $config;
$hostname = "";
if (is_array($config['dyndnses']['dyndns'])) {
$hostname = '';
if (isset($config['dyndnses']['dyndns'])) {
foreach ($config['dyndnses']['dyndns'] as $ddns) {
if (($ddns['interface'] == $interface) && isset($ddns['enable']) && !empty($ddns['host']) && !is_numeric($ddns['host']) && is_hostname($ddns['host']))
return $ddns['host'];
}
}
if (is_array($config['dnsupdates']['dnsupdate'])) {
if (isset($config['dnsupdates']['dnsupdate'])) {
foreach ($config['dnsupdates']['dnsupdate'] as $ddns) {
if (($ddns['interface'] == $interface) && isset($ddns['enable']) && !empty($ddns['host']) && !is_numeric($ddns['host']) && is_hostname($ddns['host']))
return $ddns['host'];
......
......@@ -2247,8 +2247,7 @@ function services_dnsupdate_process($int = '', $updatehost = '', $forced = false
{
global $config;
/* Dynamic DNS updating active? */
if (isset($config['dnsupdates']['dnsupdate']) && is_array($config['dnsupdates']['dnsupdate'])) {
if (isset($config['dnsupdates']['dnsupdate'])) {
$notify_text = "";
foreach ($config['dnsupdates']['dnsupdate'] as $i => $dnsupdate) {
if (!isset($dnsupdate['enable'])) {
......@@ -2259,7 +2258,6 @@ function services_dnsupdate_process($int = '', $updatehost = '', $forced = false
continue;
}
/* determine interface name */
$if = get_real_interface($dnsupdate['interface']);
if (isset($dnsupdate['usepublicip'])) {
......
......@@ -143,6 +143,7 @@ $areas = array(
'dhcrelay6' => gettext('DHCPv6 Relay'),
'dnsmasq' => gettext('DNS Forwarder'),
'dyndnses' => gettext('Dynamic DNS'),
'dnsupdates' => gettext('RFC 2136'),
'filter' => gettext('Firewall Rules'),
'gateways' => gettext('Gateways'),
'gifs' => gettext('GIF Devices'),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment