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

dns: some style and sanity for dnydnses and dnsupdates gears

parent 97cac62f
...@@ -70,28 +70,31 @@ if (function_exists("display_error_form") && !isset($config['system']['webgui'][ ...@@ -70,28 +70,31 @@ if (function_exists("display_error_form") && !isset($config['system']['webgui'][
strcasecmp($http_host, $config['system']['hostname']) == 0) strcasecmp($http_host, $config['system']['hostname']) == 0)
$found_host = true; $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) foreach($config['dyndnses']['dyndns'] as $dyndns)
if(strcasecmp($dyndns['host'], $http_host) == 0) { if(strcasecmp($dyndns['host'], $http_host) == 0) {
$found_host = true; $found_host = true;
break; break;
} }
if(isset($config['dnsupdates']['dnsupdate']) && is_array($config['dnsupdates']['dnsupdate']) && !$found_host) if (isset($config['dnsupdates']['dnsupdate']) && !$found_host) {
foreach($config['dnsupdates']['dnsupdate'] as $rfc2136) foreach ($config['dnsupdates']['dnsupdate'] as $rfc2136) {
if(strcasecmp($rfc2136['host'], $http_host) == 0) { if (strcasecmp($rfc2136['host'], $http_host) == 0) {
$found_host = true; $found_host = true;
break; break;
} }
}
}
if(!empty($config['system']['webgui']['althostnames']) && !$found_host) { if (!empty($config['system']['webgui']['althostnames']) && !$found_host) {
$althosts = explode(" ", $config['system']['webgui']['althostnames']); $althosts = explode(" ", $config['system']['webgui']['althostnames']);
foreach ($althosts as $ah) foreach ($althosts as $ah) {
if(strcasecmp($ah, $http_host) == 0 or strcasecmp($ah, $_SERVER['SERVER_ADDR']) == 0) { if (strcasecmp($ah, $http_host) == 0 or strcasecmp($ah, $_SERVER['SERVER_ADDR']) == 0) {
$found_host = true; $found_host = true;
break; break;
} }
} }
}
if($found_host == false) { if($found_host == false) {
if(!security_checks_disabled()) { if(!security_checks_disabled()) {
...@@ -122,7 +125,7 @@ if(function_exists("display_error_form") && !isset($config['system']['webgui'][' ...@@ -122,7 +125,7 @@ if(function_exists("display_error_form") && !isset($config['system']['webgui']['
|| strcasecmp($referrer_host, $config['system']['hostname']) == 0) || strcasecmp($referrer_host, $config['system']['hostname']) == 0)
$found_host = true; $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']); $althosts = explode(" ", $config['system']['webgui']['althostnames']);
foreach ($althosts as $ah) { foreach ($althosts as $ah) {
if(strcasecmp($referrer_host, $ah) == 0) { if(strcasecmp($referrer_host, $ah) == 0) {
...@@ -132,19 +135,23 @@ if(function_exists("display_error_form") && !isset($config['system']['webgui'][' ...@@ -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) if (isset($config['dyndnses']['dyndns']) && !$found_host) {
foreach($config['dyndnses']['dyndns'] as $dyndns) foreach ($config['dyndnses']['dyndns'] as $dyndns) {
if(strcasecmp($dyndns['host'], $referrer_host) == 0) { if (strcasecmp($dyndns['host'], $referrer_host) == 0) {
$found_host = true; $found_host = true;
break; break;
} }
}
}
if(isset($config['dnsupdates']['dnsupdate']) && is_array($config['dnsupdates']['dnsupdate']) && !$found_host) if (isset($config['dnsupdates']['dnsupdate']) && !$found_host) {
foreach($config['dnsupdates']['dnsupdate'] as $rfc2136) foreach ($config['dnsupdates']['dnsupdate'] as $rfc2136) {
if(strcasecmp($rfc2136['host'], $referrer_host) == 0) { if (strcasecmp($rfc2136['host'], $referrer_host) == 0) {
$found_host = true; $found_host = true;
break; break;
} }
}
}
if(!$found_host) { if(!$found_host) {
$found_host = isAuthLocalIP($referrer_host); $found_host = isAuthLocalIP($referrer_host);
......
...@@ -904,16 +904,19 @@ function openvpn_client_export_find_port_forwards($targetip, $targetport, $targe ...@@ -904,16 +904,19 @@ function openvpn_client_export_find_port_forwards($targetip, $targetport, $targe
return $destinations; return $destinations;
} }
function openvpn_client_export_find_hostname($interface) { function openvpn_client_export_find_hostname($interface)
{
global $config; global $config;
$hostname = "";
if (is_array($config['dyndnses']['dyndns'])) { $hostname = '';
if (isset($config['dyndnses']['dyndns'])) {
foreach ($config['dyndnses']['dyndns'] as $ddns) { foreach ($config['dyndnses']['dyndns'] as $ddns) {
if (($ddns['interface'] == $interface) && isset($ddns['enable']) && !empty($ddns['host']) && !is_numeric($ddns['host']) && is_hostname($ddns['host'])) if (($ddns['interface'] == $interface) && isset($ddns['enable']) && !empty($ddns['host']) && !is_numeric($ddns['host']) && is_hostname($ddns['host']))
return $ddns['host']; return $ddns['host'];
} }
} }
if (is_array($config['dnsupdates']['dnsupdate'])) { if (isset($config['dnsupdates']['dnsupdate'])) {
foreach ($config['dnsupdates']['dnsupdate'] as $ddns) { foreach ($config['dnsupdates']['dnsupdate'] as $ddns) {
if (($ddns['interface'] == $interface) && isset($ddns['enable']) && !empty($ddns['host']) && !is_numeric($ddns['host']) && is_hostname($ddns['host'])) if (($ddns['interface'] == $interface) && isset($ddns['enable']) && !empty($ddns['host']) && !is_numeric($ddns['host']) && is_hostname($ddns['host']))
return $ddns['host']; return $ddns['host'];
......
...@@ -2247,8 +2247,7 @@ function services_dnsupdate_process($int = '', $updatehost = '', $forced = false ...@@ -2247,8 +2247,7 @@ function services_dnsupdate_process($int = '', $updatehost = '', $forced = false
{ {
global $config; global $config;
/* Dynamic DNS updating active? */ if (isset($config['dnsupdates']['dnsupdate'])) {
if (isset($config['dnsupdates']['dnsupdate']) && is_array($config['dnsupdates']['dnsupdate'])) {
$notify_text = ""; $notify_text = "";
foreach ($config['dnsupdates']['dnsupdate'] as $i => $dnsupdate) { foreach ($config['dnsupdates']['dnsupdate'] as $i => $dnsupdate) {
if (!isset($dnsupdate['enable'])) { if (!isset($dnsupdate['enable'])) {
...@@ -2259,7 +2258,6 @@ function services_dnsupdate_process($int = '', $updatehost = '', $forced = false ...@@ -2259,7 +2258,6 @@ function services_dnsupdate_process($int = '', $updatehost = '', $forced = false
continue; continue;
} }
/* determine interface name */
$if = get_real_interface($dnsupdate['interface']); $if = get_real_interface($dnsupdate['interface']);
if (isset($dnsupdate['usepublicip'])) { if (isset($dnsupdate['usepublicip'])) {
......
...@@ -143,6 +143,7 @@ $areas = array( ...@@ -143,6 +143,7 @@ $areas = array(
'dhcrelay6' => gettext('DHCPv6 Relay'), 'dhcrelay6' => gettext('DHCPv6 Relay'),
'dnsmasq' => gettext('DNS Forwarder'), 'dnsmasq' => gettext('DNS Forwarder'),
'dyndnses' => gettext('Dynamic DNS'), 'dyndnses' => gettext('Dynamic DNS'),
'dnsupdates' => gettext('RFC 2136'),
'filter' => gettext('Firewall Rules'), 'filter' => gettext('Firewall Rules'),
'gateways' => gettext('Gateways'), 'gateways' => gettext('Gateways'),
'gifs' => gettext('GIF Devices'), '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