Commit 0077ff23 authored by Franco Fichtner's avatar Franco Fichtner

dynamic dns: merge recent rework from master

* Now fully pluggable and scheduled for core removal in 17.7
* Added IPv6 functionality to IP probe function
* Multiple fixes in the GUI handling
* Separated RFC 2136 backend
* New RFC 2136 widget
* Style consolidation
parent c6776eb2
......@@ -15,8 +15,6 @@
/usr/local/etc/inc/config.inc
/usr/local/etc/inc/config.lib.inc
/usr/local/etc/inc/crypt.inc
/usr/local/etc/inc/dyndns.class
/usr/local/etc/inc/dyndns.r53.class
/usr/local/etc/inc/filter.inc
/usr/local/etc/inc/filter.lib.inc
/usr/local/etc/inc/filter_log.inc
......@@ -42,6 +40,9 @@
/usr/local/etc/inc/openvpn_wizard.inc
/usr/local/etc/inc/plugins.inc
/usr/local/etc/inc/plugins.inc.d/dnsmasq.inc
/usr/local/etc/inc/plugins.inc.d/dyndns.inc
/usr/local/etc/inc/plugins.inc.d/dyndns/phpDynDNS.inc
/usr/local/etc/inc/plugins.inc.d/dyndns/r53.inc
/usr/local/etc/inc/plugins.inc.d/if_ipsec.inc
/usr/local/etc/inc/plugins.inc.d/if_openvpn.inc
/usr/local/etc/inc/plugins.inc.d/ipfw.inc
......@@ -49,6 +50,7 @@
/usr/local/etc/inc/plugins.inc.d/ntpd.inc
/usr/local/etc/inc/plugins.inc.d/openssh.inc
/usr/local/etc/inc/plugins.inc.d/pf.inc
/usr/local/etc/inc/plugins.inc.d/rfc2136.inc
/usr/local/etc/inc/plugins.inc.d/squid.inc
/usr/local/etc/inc/plugins.inc.d/squid/auth-user.php
/usr/local/etc/inc/plugins.inc.d/suricata.inc
......@@ -83,7 +85,7 @@
/usr/local/etc/rc.d/configd
/usr/local/etc/rc.d/flowd_aggregate
/usr/local/etc/rc.d/netflow
/usr/local/etc/rc.dyndns.update
/usr/local/etc/rc.dyndns
/usr/local/etc/rc.expireaccounts
/usr/local/etc/rc.filter_configure
/usr/local/etc/rc.filter_synchronize
......@@ -129,6 +131,7 @@
/usr/local/etc/rc.reload_interfaces
/usr/local/etc/rc.resolv_conf_generate
/usr/local/etc/rc.restart_webgui
/usr/local/etc/rc.rfc2136
/usr/local/etc/rc.shutdown
/usr/local/etc/rc.sshd
/usr/local/etc/rc.syshook
......@@ -442,6 +445,8 @@
/usr/local/opnsense/mvc/app/models/OPNsense/Diagnostics/Migrations/M1_0_0.php
/usr/local/opnsense/mvc/app/models/OPNsense/Diagnostics/Netflow.php
/usr/local/opnsense/mvc/app/models/OPNsense/Diagnostics/Netflow.xml
/usr/local/opnsense/mvc/app/models/OPNsense/DynamicDNS/ACL/ACL.xml
/usr/local/opnsense/mvc/app/models/OPNsense/DynamicDNS/Menu/Menu.xml
/usr/local/opnsense/mvc/app/models/OPNsense/IDS/ACL/ACL.xml
/usr/local/opnsense/mvc/app/models/OPNsense/IDS/IDS.php
/usr/local/opnsense/mvc/app/models/OPNsense/IDS/IDS.xml
......@@ -454,6 +459,8 @@
/usr/local/opnsense/mvc/app/models/OPNsense/Proxy/Migrations/M1_0_0.php
/usr/local/opnsense/mvc/app/models/OPNsense/Proxy/Proxy.php
/usr/local/opnsense/mvc/app/models/OPNsense/Proxy/Proxy.xml
/usr/local/opnsense/mvc/app/models/OPNsense/RFC2136/ACL/ACL.xml
/usr/local/opnsense/mvc/app/models/OPNsense/RFC2136/Menu/Menu.xml
/usr/local/opnsense/mvc/app/models/OPNsense/TrafficShaper/ACL/ACL.xml
/usr/local/opnsense/mvc/app/models/OPNsense/TrafficShaper/Menu/Menu.xml
/usr/local/opnsense/mvc/app/models/OPNsense/TrafficShaper/Migrations/M1_0_0.php
......@@ -632,6 +639,7 @@
/usr/local/opnsense/service/conf/actions.d/actions_openssh.conf
/usr/local/opnsense/service/conf/actions.d/actions_openvpn.conf
/usr/local/opnsense/service/conf/actions.d/actions_proxy.conf
/usr/local/opnsense/service/conf/actions.d/actions_rfc2136.conf
/usr/local/opnsense/service/conf/actions.d/actions_routedns.conf
/usr/local/opnsense/service/conf/actions.d/actions_system.conf
/usr/local/opnsense/service/conf/actions.d/actions_systemhealth.conf
......@@ -1112,6 +1120,7 @@
/usr/local/www/widgets/include/log.inc
/usr/local/www/widgets/include/ntp_status.inc
/usr/local/www/widgets/include/openvpn.inc
/usr/local/www/widgets/include/rfc2136.inc
/usr/local/www/widgets/include/services_status.inc
/usr/local/www/widgets/include/system_log.inc
/usr/local/www/widgets/include/thermal_sensors.inc
......@@ -1126,6 +1135,7 @@
/usr/local/www/widgets/widgets/ntp_status.widget.php
/usr/local/www/widgets/widgets/openvpn.widget.php
/usr/local/www/widgets/widgets/picture.widget.php
/usr/local/www/widgets/widgets/rfc2136.widget.php
/usr/local/www/widgets/widgets/rss.widget.php
/usr/local/www/widgets/widgets/services_status.widget.php
/usr/local/www/widgets/widgets/system_information.widget.php
......
This diff is collapsed.
......@@ -92,8 +92,8 @@ rrd interval 60s;
## These parameters can be overridden in a specific alarm configuration
alarm default {
command on "/usr/local/opnsense/service/configd_ctl.py -m 'dyndns reload %T' 'ipsecdns reload' 'openvpn reload %T' 'filter reload' "
command off "/usr/local/opnsense/service/configd_ctl.py -m 'dyndns reload %T' 'ipsecdns reload' 'openvpn reload %T' 'filter reload' "
command on "/usr/local/opnsense/service/configd_ctl.py -m 'dyndns reload %T' 'rfc2136 reload %T' 'ipsecdns reload' 'openvpn reload %T' 'filter reload' "
command off "/usr/local/opnsense/service/configd_ctl.py -m 'dyndns reload %T' 'rfc2136 reload %T' 'ipsecdns reload' 'openvpn reload %T' 'filter reload' "
combine 10s
}
......
......@@ -2778,6 +2778,7 @@ function interface_configure($interface = 'wan', $reloadall = false, $linkupeven
/* update dyndns */
configd_run("dyndns reload {$interface}");
configd_run("rfc2136 reload {$interface}");
}
}
......
<?php
/*
Copyright (C) 2014-2017 Franco Fichtner <franco@opnsense.org>
Copyright (C) 2010 Ermal Luci
Copyright (C) 2005-2006 Colin Smith <ethethlay@gmail.com>
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
require_once('plugins.inc.d/dyndns/phpDynDNS.inc');
require_once('plugins.inc.d/dyndns/r53.inc');
function dyndns_configure()
{
return array(
'bootup' => array('dyndns_configure_do'),
'local' => array('dyndns_configure_do'),
'interface' => array('dyndns_configure_do:2'),
);
}
function dyndns_enabled()
{
global $config;
if (isset($config['dyndnses']['dyndns'])) {
foreach ($config['dyndnses']['dyndns'] as $conf) {
if (isset($conf['enable'])) {
return true;
}
}
}
return false;
}
function dyndns_services()
{
global $config;
$services = array();
if (dyndns_enabled()) {
$services[] = array(
'description' => gettext('Dynamic DNS'),
'configd' => array(
'restart' => array('dyndns reload'),
),
'nocheck' => true,
'name' => 'dyndns',
);
}
return $services;
}
function dyndns_cron()
{
$jobs = array();
if (dyndns_enabled()) {
$jobs[]['autocron'] = array('/usr/local/etc/rc.dyndns', '11', '1');
}
return $jobs;
}
function dyndns_list()
{
return array(
'citynetwork' => 'City Network',
'cloudflare' => 'CloudFlare',
'custom' => 'Custom',
'custom-v6' => 'Custom (v6)',
'dhs' => 'DHS',
'dnsexit' => 'DNSexit',
'dnsomatic' => 'DNS-O-Matic',
'duckdns' => 'Duck DNS',
'dyndns' => 'DynDNS (dynamic)',
'dyndns-static' => 'DynDNS (static)',
'dyndns-custom' => 'DynDNS (custom)',
'dyns' => 'DyNS',
'easydns' => 'easyDNS',
'eurodns' => 'EuroDNS',
'freedns' => 'freeDNS',
'gratisdns' => 'GratisDNS',
'googledomains' => 'Google Domains',
'he-net' => 'HE.net',
'he-net-v6' => 'HE.net (v6)',
'he-net-tunnelbroker' => 'HE.net Tunnelbroker',
'loopia' => 'Loopia',
'namecheap' => 'Namecheap',
'noip' => 'No-IP',
'noip-free' => 'No-IP (free)',
'ods' => 'ODS.org',
'opendns' => 'OpenDNS',
'ovh-dynhost' => 'OVH DynHOST',
'route53' => 'Route 53',
'selfhost' => 'SelfHost',
'zoneedit' => 'ZoneEdit',
);
}
function dyndns_cache_file($conf, $ipver = 4)
{
$ipver = $ipver == 6 ? '_v6' : '';
return "/var/cache/dyndns_{$conf['interface']}_{$conf['host']}_{$conf['id']}{$ipver}.cache";
}
function dyndns_configure_client($conf)
{
if (!isset($conf['enable'])) {
return;
}
$dns = new updatedns($dnsService = $conf['type'],
$dnsHost = $conf['host'],
$dnsUser = $conf['username'],
$dnsPass = $conf['password'],
$dnsWilcard = $conf['wildcard'],
$dnsMX = $conf['mx'],
$dnsIf = "{$conf['interface']}",
$dnsBackMX = NULL,
$dnsServer = NULL,
$dnsPort = NULL,
$dnsUpdateURL = "{$conf['updateurl']}",
$forceUpdate = $conf['force'],
$dnsZoneID=$conf['zoneid'],
$dnsTTL=$conf['ttl'],
$dnsResultMatch = "{$conf['resultmatch']}",
$dnsRequestIf = "{$conf['requestif']}",
$dnsID = "{$conf['id']}",
$dnsVerboseLog = $conf['verboselog'],
$curlIpresolveV4 = $conf['curl_ipresolve_v4'],
$curlSslVerifypeer = $conf['curl_ssl_verifypeer']
);
}
function dyndns_configure_do($verbose = false, $int = '')
{
global $config;
if (!dyndns_enabled()) {
return;
}
$dyndnscfg = $config['dyndnses']['dyndns'];
$gwgroups = return_gateway_groups_array();
if ($verbose) {
echo 'Configuring dynamic DNS clients...';
flush();
}
foreach ($dyndnscfg as $dyndns) {
if ((empty($int)) || ($int == $dyndns['interface']) || (is_array($gwgroups[$dyndns['interface']]))) {
$dyndns['verboselog'] = isset($dyndns['verboselog']);
$dyndns['curl_ipresolve_v4'] = isset($dyndns['curl_ipresolve_v4']);
$dyndns['curl_ssl_verifypeer'] = isset($dyndns['curl_ssl_verifypeer']);
dyndns_configure_client($dyndns);
sleep(1);
}
}
if ($verbose) {
echo "done.\n";
}
}
This diff is collapsed.
<?php
/*
Copyright (C) 2014-2017 Franco Fichtner <franco@opnsense.org>
Copyright (C) 2010 Ermal Luci
Copyright (C) 2005-2006 Colin Smith <ethethlay@gmail.com>
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
function rfc2136_configure()
{
return array(
'bootup' => array('rfc2136_configure_do'),
'local' => array('rfc2136_configure_do'),
'interface' => array('rfc2136_configure_do:2'),
);
}
function rfc2136_enabled()
{
global $config;
if (isset($config['dnsupdates']['dnsupdate'])) {
foreach ($config['dnsupdates']['dnsupdate'] as $dnsupdate) {
if (isset($dnsupdate['enable'])) {
return true;
}
}
}
return false;
}
function rfc2136_services()
{
global $config;
$services = array();
if (rfc2136_enabled()) {
$services[] = array(
'description' => gettext('RFC 2136'),
'configd' => array(
'restart' => array('rfc2136 reload'),
),
'nocheck' => true,
'name' => 'rfc2136',
);
}
return $services;
}
function rfc2136_cron()
{
$jobs = array();
if (rfc2136_enabled()) {
$jobs[]['autocron'] = array('/usr/local/etc/rc.rfc2136', '16', '1');
}
return $jobs;
}
function rfc2136_cache_file($dnsupdate, $ipver = 4)
{
$ipver = $ipver == 6 ? '_v6' : '';
return "/var/cache/rfc2136_{$dnsupdate['interface']}_{$dnsupdate['host']}_{$dnsupdate['server']}{$ipver}.cache";
}
function rfc2136_configure_do($verbose = false, $int = '', $updatehost = '', $forced = false)
{
global $config;
if (!rfc2136_enabled()) {
return;
}
$notify_text = '';
if ($verbose) {
echo 'Configuring RFC 2136 clients...';
flush();
}
foreach ($config['dnsupdates']['dnsupdate'] as $i => $dnsupdate) {
if (!isset($dnsupdate['enable'])) {
continue;
} elseif (!empty($int) && $int != $dnsupdate['interface']) {
continue;
} elseif (!empty($updatehost) && ($updatehost != $dnsupdate['host'])) {
continue;
}
$currentTime = time();
$keyname = $dnsupdate['keyname'];
/* trailing dot */
if (substr($keyname, -1) != ".") {
$keyname .= ".";
}
$hostname = $dnsupdate['host'];
/* trailing dot */
if (substr($hostname, -1) != ".") {
$hostname .= ".";
}
/* write private key file
this is dumb - public and private keys are the same for HMAC-MD5,
but nsupdate insists on having both */
$fd = fopen("/var/etc/K{$i}{$keyname}+157+00000.private", "w");
$privkey = <<<EOD
Private-key-format: v1.2
Algorithm: 157 (HMAC)
Key: {$dnsupdate['keydata']}
EOD;
fwrite($fd, $privkey);
fclose($fd);
/* write public key file */
if ($dnsupdate['keytype'] == "zone") {
$flags = 257;
$proto = 3;
} elseif ($dnsupdate['keytype'] == "host") {
$flags = 513;
$proto = 3;
} elseif ($dnsupdate['keytype'] == "user") {
$flags = 0;
$proto = 2;
}
$fd = fopen("/var/etc/K{$i}{$keyname}+157+00000.key", "w");
fwrite($fd, "{$keyname} IN KEY {$flags} {$proto} 157 {$dnsupdate['keydata']}\n");
fclose($fd);
/* generate update instructions */
$upinst = "";
if (!empty($dnsupdate['server'])) {
$upinst .= "server {$dnsupdate['server']}\n";
}
$maxCacheAgeSecs = 25 * 24 * 60 * 60;
$need_update = false;
if (empty($dnsupdate['recordtype']) || $dnsupdate['recordtype'] == 'A') {
$cacheFile = rfc2136_cache_file($dnsupdate, 4);
if (file_exists($cacheFile)) {
list($cachedipv4, $cacheTimev4) = explode('|', file_get_contents($cacheFile));
} else {
list($cachedipv4, $cacheTimev4) = array('', '');
}
if (isset($dnsupdate['usepublicip'])) {
$wanip = get_dyndns_ip($dnsupdate['interface'], 4);
} else {
$wanip = get_interface_ip($dnsupdate['interface']);
}
if (is_ipaddrv4($wanip)) {
if (($wanip != $cachedipv4) || (($currentTime - $cacheTimev4) > $maxCacheAgeSecs) || $forced) {
$upinst .= "update delete {$dnsupdate['host']}. A\n";
$upinst .= "update add {$dnsupdate['host']}. {$dnsupdate['ttl']} A {$wanip}\n";
$notify_text .= sprintf(gettext('Dynamic DNS updated IP Address (A) for %s on %s to %s'), $dnsupdate['host'], strtoupper($dnsupdate['interface']), $wanip) . "\n";
@file_put_contents($cacheFile, "{$wanip}|{$currentTime}");
log_error("Dynamic DNS: updating cache file {$cacheFile}: {$wanip}");
$need_update = true;
} else {
log_error("Dynamic DNS: Not updating {$dnsupdate['host']} A record because the IP address has not changed.");
}
} else {
@unlink($cacheFile);
}
}
if (empty($dnsupdate['recordtype']) || $dnsupdate['recordtype'] == 'AAAA') {
$cacheFile6 = rfc2136_cache_file($dnsupdate, 6);
if (file_exists($cacheFile6)) {
list($cachedipv6, $cacheTimev6) = explode('|', file_get_contents($cacheFile6));
} else {
list($cachedipv6, $cacheTimev6) = array('', '');
}
if (isset($dnsupdate['usepublicip'])) {
$wanipv6 = get_dyndns_ip($dnsupdate['interface'], 6);
} else {
$wanipv6 = get_interface_ipv6($dnsupdate['interface']);
}
if (is_ipaddrv6($wanipv6)) {
if (($wanipv6 != $cachedipv6) || (($currentTime - $cacheTimev6) > $maxCacheAgeSecs) || $forced) {
$upinst .= "update delete {$dnsupdate['host']}. AAAA\n";
$upinst .= "update add {$dnsupdate['host']}. {$dnsupdate['ttl']} AAAA {$wanipv6}\n";
$notify_text .= sprintf(gettext('Dynamic DNS updated IPv6 Address (AAAA) for %s on %s to %s'), $dnsupdate['host'], strtoupper($dnsupdate['interface']), $wanipv6) . "\n";
@file_put_contents($cacheFile6, "{$wanipv6}|{$currentTime}");
log_error("Dynamic DNS: updating cache file {$cacheFile6}: {$wanipv6}");
$need_update = true;
} else {
log_error("Dynamic DNS: Not updating {$dnsupdate['host']} AAAA record because the IPv6 address has not changed.");
}
} else {
@unlink($cacheFile6);
}
}
$upinst .= "\n"; /* mind that trailing newline! */
if ($need_update) {
@file_put_contents("/var/etc/nsupdatecmds{$i}", $upinst);
unset($upinst);
/* invoke nsupdate */
$cmd = "/usr/local/bin/nsupdate -k /var/etc/K{$i}{$keyname}+157+00000.key";
if (isset($dnsupdate['usetcp']))
$cmd .= " -v";
$cmd .= " /var/etc/nsupdatecmds{$i}";
mwexec_bg($cmd);
unset($cmd);
}
}
if (!empty($notify_text)) {
notify_all_remote($notify_text);
}
if ($verbose) {
echo "done.\n";
}
}
This diff is collapsed.
......@@ -1597,7 +1597,6 @@ function system_cron_configure($verbose = false)
/* daily */
$autocron[] = generate_cron_job('/usr/local/etc/rc.update_alias_url_data', '1', '1');
$autocron[] = generate_cron_job('/usr/local/etc/rc.update_urltables', '6', '1');
$autocron[] = generate_cron_job('/usr/local/etc/rc.dyndns.update', '11', '1');
/* every now and then */
$autocron[] = generate_cron_job('/usr/local/sbin/ping_hosts.sh', '*/4');
......
......@@ -110,8 +110,6 @@ system_hosts_generate(true);
services_dhcrelay_configure(true);
services_dhcrelay6_configure(true);
mwexec("/usr/local/etc/rc.dyndns.update"); /* XXX convert to plugin */
prefer_ipv4_or_ipv6();
filter_configure_sync(true);
......
......@@ -32,22 +32,20 @@ require_once("interfaces.inc");
require_once("util.inc");
require_once("filter.inc");
require_once("services.inc");
/* Interface IP address has changed */
require_once("plugins.inc.d/dyndns.inc");
if (isset($argv[1])) {
$argument = trim($argv[1], " \n");
$argument = trim($argv[1], " \n");
} else {
$argument = null;
$argument = null;
}
if(empty($argument)) {
services_dyndns_configure();
services_dnsupdate_process();
if (empty($argument)) {
dyndns_configure_do(true);
} else {
$interface = lookup_gateway_interface_by_name($argument);
if (empty($interface))
$interface = $argument;
services_dyndns_configure($interface);
services_dnsupdate_process($interface);
$interface = lookup_gateway_interface_by_name($argument);
if (empty($interface)) {
$interface = $argument;
}
dyndns_configure_do(true, $interface);
}
......@@ -181,12 +181,6 @@ if (!is_ipaddr($oldip) || $curwanip != $oldip || !is_ipaddrv4($config['interface
@file_put_contents("/var/db/{$interface}_cacheip", $curwanip);
}
/* perform RFC 2136 DNS update */
services_dnsupdate_process($interface);
/* signal dyndns update */
services_dyndns_configure($interface);
/* reconfigure IPsec tunnels */
if (ipsec_configured_on_interface($interface)) {
ipsec_configure();
......
......@@ -138,12 +138,6 @@ if (is_ipaddrv6($oldipv6)) {
file_put_contents("/var/db/{$interface}_cacheipv6", $curwanipv6);
}
/* perform RFC 2136 DNS update */
services_dnsupdate_process($interface);
/* signal dyndns update */
services_dyndns_configure($interface);
/* reconfigure IPsec tunnels */
if (ipsec_configured_on_interface($interface)) {
ipsec_configure();
......
......@@ -60,7 +60,6 @@ system_hosts_generate(true);
system_resolvconf_generate(true);
services_dhcpd_configure('all', array(), true);
interfaces_configure(true);
services_dyndns_configure('', true);
system_cron_configure(true);
log_error("rc.reload_all: Reloading all plugin settings.");
......
#!/usr/local/bin/php
<?php
/*
Copyright (C) 2004 Scott Ullrich
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
require_once("config.inc");
require_once("interfaces.inc");
require_once("util.inc");
require_once("filter.inc");
require_once("services.inc");
require_once("plugins.inc.d/rfc2136.inc");
if (isset($argv[1])) {
$argument = trim($argv[1], " \n");
} else {
$argument = null;
}
if (empty($argument)) {
rfc2136_configure_do(true);
} else {
$interface = lookup_gateway_interface_by_name($argument);
if (empty($interface)) {
$interface = $argument;
}
rfc2136_configure_do(true, $interface);
}
......@@ -247,13 +247,7 @@
</ACL>
</DNSResolver>
<DNSTools VisibleName="DNS Tools" cssClass="fa fa-tags fa-fw">
<DynamicDNS VisibleName="Dynamic DNS" order="10" url="/services_dyndns.php">
<Edit url="/services_dyndns_edit.php*" visibility="hidden"/>
</DynamicDNS>
<Filter order="20" url="/services_opendns.php"/>
<RFC2136 order="30" VisibleName="RFC 2136" url="/services_rfc2136.php">
<Edit url="/services_rfc2136_edit.php*" visibility="hidden"/>
</RFC2136>
<LogFile order="100" VisibleName="Log File" url="/diag_logs_resolver.php"/>
</DNSTools>
<Diagnostics order="900" cssClass="fa fa-medkit fa-fw" url="/status_services.php">
......
......@@ -551,24 +551,6 @@
<pattern>services_unbound_host_edit.php*</pattern>
</patterns>
</page-services-dnsresolver-edithost>
<page-services-dynamicdnsclient>
<name>Services: Dynamic DNS client</name>
<patterns>
<pattern>services_dyndns_edit.php*</pattern>
</patterns>
</page-services-dynamicdnsclient>
<page-services-dynamicdnsclients>
<name>Services: Dynamic DNS clients</name>
<patterns>
<pattern>services_dyndns.php*</pattern>
</patterns>
</page-services-dynamicdnsclients>
<page-services-rfc2136clients>
<name>Services: RFC 2136 clients</name>
<patterns>
<pattern>services_rfc2136.php*</pattern>
</patterns>
</page-services-rfc2136clients>
<page-services-router-advertisements>
<name>Services: Router advertisements</name>
<patterns>
......
<acl>
<page-services-dynamicdnsclients>
<name>Services: Dynamic DNS clients</name>
<patterns>
<pattern>services_dyndns.php*</pattern>
<pattern>services_dyndns_edit.php*</pattern>
</patterns>
</page-services-dynamicdnsclients>
</acl>
<menu>
<Services>
<DynamicDNS VisibleName="Dynamic DNS" url="/services_dyndns.php" cssClass="fa fa-tags fa-fw">
<Edit url="/services_dyndns_edit.php*" visibility="hidden"/>
</DynamicDNS>
</Services>
</menu>
<acl>
<page-services-rfc2136clients>
<name>Services: RFC 2136 clients</name>
<patterns>
<pattern>services_rfc2136.php*</pattern>
<pattern>services_rfc2136_edit.php*</pattern>
</patterns>
</page-services-rfc2136clients>
</acl>
<menu>
<Services>
<RFC2136 VisibleName="RFC 2136" url="/services_rfc2136.php" cssClass="fa fa-tags fa-fw">
<Edit url="/services_rfc2136_edit.php*" visibility="hidden"/>
</RFC2136>
</Services>
</menu>
[reload]
command:/usr/local/etc/rc.dyndns.update
command:/usr/local/etc/rc.dyndns
description:Dynamic DNS Update
parameters:%s
type:script
......
[reload]
command:/usr/local/etc/rc.rfc2136
description:RFC 2136 Update
parameters:%s
type:script
message:updating rfc2136 %s
......@@ -30,7 +30,8 @@
require_once("guiconfig.inc");
require_once("interfaces.inc");
require_once("services.inc");
require_once("interfaces.inc");
require_once("system.inc");
require_once("plugins.inc.d/dyndns.inc");
if (empty($config['dyndnses']['dyndns']) || !isset($config['dyndnses']['dyndns'])) {
$config['dyndnses']['dyndns'] = array();
......@@ -41,10 +42,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_POST['act']) && $_POST['act'] == "del" && isset($_POST['id'])) {
if (!empty($a_dyndns[$_POST['id']])) {
$conf = $a_dyndns[$_POST['id']];
@unlink("/conf/dyndns_{$conf['interface']}{$conf['type']}" . escapeshellarg($conf['host']) . "{$conf['id']}.cache");
@unlink(dyndns_cache_file($conf, 4));
@unlink(dyndns_cache_file($conf, 6));
unset($a_dyndns[$_POST['id']]);
write_config();
configd_run('dyndns reload', true);
system_cron_configure();
}
exit;
} elseif (isset($_POST['act']) && $_POST['act'] == "toggle" && isset($_POST['id'])) {
......@@ -55,20 +57,25 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$a_dyndns[$_POST['id']]['enable'] = true;
}
write_config();
configd_run('dyndns reload', true);
system_cron_configure();
if ($a_dyndns[$_POST['id']]['enable']) {
$a_dyndns[$_POST['id']]['force'] = true;
dyndns_configure_client($a_dyndns[$_POST['id']]);
}
}
exit;
}
}
include("head.inc");
legacy_html_escape_form_data($a_dyndns);
$main_buttons = array(
array('label'=>gettext('Add'), 'href'=>'services_dyndns_edit.php'),
array('label' => gettext('Add'), 'href' => 'services_dyndns_edit.php'),
);
?>
?>
<body>
<script type="text/javascript">
$( document ).ready(function() {
......@@ -78,7 +85,7 @@ $main_buttons = array(
var id = $(this).data("id");
BootstrapDialog.show({
type:BootstrapDialog.TYPE_DANGER,
title: "<?= gettext("DynDNS");?>",
title: "<?= gettext("Dynamic DNS");?>",
message: "<?=gettext("Do you really want to delete this entry?");?>",
buttons: [{
label: "<?= gettext("No");?>",
......@@ -136,26 +143,26 @@ $main_buttons = array(
</a>
<?=!empty($config['interfaces'][$dyndns['interface']]['descr']) ? $config['interfaces'][$dyndns['interface']]['descr'] : strtoupper($dyndns['interface']);?>
</td>
<td><?=services_dyndns_list()[$dyndns['type']];?></td>
<td><?=dyndns_list()[$dyndns['type']];?></td>
<td><?=$dyndns['host'];?></td>
<td>
<?php
$filename = "/conf/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}.cache";
$filename = dyndns_cache_file($dyndns, 4);
$fdata = '';
if (file_exists($filename) && !empty($dyndns['enable'])) {
$ipaddr = dyndnsCheckIP($dyndns['interface']);
$ipaddr = get_dyndns_ip($dyndns['interface'], 4);
$fdata = @file_get_contents($filename);
}
$filename_v6 = "/conf/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}_v6.cache";
$filename_v6 = dyndns_cache_file($dyndns, 6);
$fdata6 = '';
if (file_exists($filename_v6) && !empty($dyndns['enable'])) {
$ipv6addr = get_interface_ipv6($dyndns['interface']);
$ipv6addr = get_dyndns_ip($dyndns['interface'], 6);
$fdata6 = @file_get_contents($filename_v6);
}
if (!empty($fdata)) {
$cached_ip_s = explode(':', $fdata);
$cached_ip_s = explode('|', $fdata);
$cached_ip = $cached_ip_s[0];
echo sprintf(
'<font color="%s">%s</font>',
......@@ -183,11 +190,6 @@ $main_buttons = array(
<?php
$i++;
endforeach; ?>
<tr>
<td colspan="6" class="list">
<?=gettext("You can force an update for an IP address on the edit page for that service.");?>
</td>
</tr>
</tbody>
</table>
</div>
......
......@@ -30,6 +30,8 @@
require_once("guiconfig.inc");
require_once("services.inc") ;
require_once("interfaces.inc");
require_once("system.inc");
require_once("plugins.inc.d/dyndns.inc");
/* returns true if $uname is a valid dynamic DNS username */
function is_dyndns_username($uname)
......@@ -161,17 +163,22 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
}
write_config();
services_dyndns_configure_client($dyndns);
system_cron_configure();
if ($dyndns['force']) {
dyndns_configure_client($dyndns);
}
header(url_safe('Location: /services_dyndns.php'));
exit;
}
}
legacy_html_escape_form_data($pconfig);
include("head.inc");
?>
?>
<body>
<?php include("fbegin.inc"); ?>
<script type="text/javascript">
......@@ -223,7 +230,7 @@ include("head.inc");
<td>
<select name="type" class="selectpicker" id="type">
<?php
foreach (services_dyndns_list() as $value => $type):?>
foreach (dyndns_list() as $value => $type):?>
<option value="<?= $value ?>" <?= $value == $pconfig['type'] ? 'selected="selected"' : '' ?>>
<?= $type ?>
</option>
......@@ -391,14 +398,14 @@ include("head.inc");
<tr>
<td>&nbsp;</td>
<td>
<input name="Submit" type="submit" class="btn btn-primary" value="<?= gettext("Save") ?>" onclick="enable_change(true)" />
<button name="submit" type="submit" class="btn btn-primary" value="save"><?= gettext('Save') ?></button>
<?php
if (isset($id)): ?>
<button name="force" type="submit" class="btn btn-primary" value="force"><?= gettext('Save and Force Update') ?></button>
<input name="id" type="hidden" value="<?= $id ?>" />
<input name="force" type="submit" class="btn btn-primary" value="<?= gettext("Save & Force Update") ?>" onclick="enable_change(true)" />
<?php
endif; ?>
<a href="services_dyndns.php" class="btn btn-default"><?= gettext("Cancel") ?></a>
<a href="services_dyndns.php" class="btn btn-default"><?= gettext('Cancel') ?></a>
</td>
</tr>
<tr>
......
......@@ -30,6 +30,8 @@
require_once("guiconfig.inc");
require_once("interfaces.inc");
require_once("services.inc");
require_once("system.inc");
require_once("plugins.inc.d/rfc2136.inc");
if (!isset($config['dnsupdates']['dnsupdate'])) {
$config['dnsupdates']['dnsupdate'] = array();
......@@ -40,9 +42,11 @@ $a_rfc2136 = &$config['dnsupdates']['dnsupdate'];
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_POST['act']) && $_POST['act'] == "del" && isset($_POST['id'])) {
if (!empty($a_rfc2136[$_POST['id']])) {
@unlink(rfc2136_cache_file($a_rfc2136[$_POST['id']], 4));
@unlink(rfc2136_cache_file($a_rfc2136[$_POST['id']], 6));
unset($a_rfc2136[$_POST['id']]);
write_config();
configd_run('dyndns reload', true);
system_cron_configure();
}
exit;
} elseif (isset($_POST['act']) && $_POST['act'] == "toggle" && isset($_POST['id'])) {
......@@ -53,20 +57,24 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$a_rfc2136[$_POST['id']]['enable'] = true;
}
write_config();
configd_run('dyndns reload', true);
system_cron_configure();
if (!empty($a_rfc2136[$_POST['id']]['enable'])) {
rfc2136_configure_do(false, '', $a_rfc2136[$_POST['id']]['host'], true);
}
}
exit;
}
}
include("head.inc");
legacy_html_escape_form_data($a_rfc2136);
$main_buttons = array(
array('label' => gettext('Add'), 'href' => 'services_rfc2136_edit.php'),
);
?>
?>
<body>
<script type="text/javascript">
$( document ).ready(function() {
......@@ -139,11 +147,11 @@ $main_buttons = array(
<td><?=$rfc2136['host'];?></td>
<td>
<?php
$filename = "/conf/dyndns_{$rfc2136['interface']}_rfc2136_" . escapeshellarg($rfc2136['host']) . "_{$rfc2136['server']}.cache";
if (file_exists($filename) && !empty($rfc2136['enable']) && (empty($dnsupdate['recordtype']) || $dnsupdate['recordtype'] == 'A')) {
$filename = rfc2136_cache_file($rfc2136, 4);
if (file_exists($filename) && !empty($rfc2136['enable']) && (empty($rfc2136['recordtype']) || $rfc2136['recordtype'] == 'A')) {
echo "IPv4: ";
if (isset($rfc2136['usepublicip'])) {
$ipaddr = dyndnsCheckIP($rfc2136['interface']);
$ipaddr = get_dyndns_ip($rfc2136['interface'], 4);
} else {
$ipaddr = get_interface_ip($rfc2136['interface']);
}
......@@ -157,13 +165,18 @@ $main_buttons = array(
echo htmlspecialchars($cached_ip);
echo "</font>";
} else {
echo "IPv4: N/A";
echo 'IPv4: ' . gettext('N/A');
}
echo "<br />";
if (file_exists("{$filename}.ipv6") && !empty($rfc2136['enable']) && (empty($dnsupdate['recordtype']) || $dnsupdate['recordtype'] == 'AAAA')) {
$filename6 = rfc2136_cache_file($rfc2136, 6);
if (file_exists($filename6) && !empty($rfc2136['enable']) && (empty($rfc2136['recordtype']) || $rfc2136['recordtype'] == 'AAAA')) {
echo "IPv6: ";
$ipaddr = get_interface_ipv6($rfc2136['interface']);
$cached_ip_s = explode("|", file_get_contents("{$filename}.ipv6"));
if (isset($rfc2136['usepublicip'])) {
$ipaddr = get_dyndns_ip($rfc2136['interface'], 6);
} else {
$ipaddr = get_interface_ipv6($rfc2136['interface']);
}
$cached_ip_s = explode("|", file_get_contents($filename6));
$cached_ip = $cached_ip_s[0];
if ($ipaddr <> $cached_ip) {
echo "<font color='red'>";
......@@ -173,7 +186,7 @@ $main_buttons = array(
echo htmlspecialchars($cached_ip);
echo "</font>";
} else {
echo "IPv6: N/A";
echo 'IPv6: ' . gettext('N/A');
}?>
</td>
<td><?=$rfc2136['descr'];?></td>
......
......@@ -29,7 +29,9 @@
require_once("guiconfig.inc");
require_once("services.inc");
require_once("system.inc");
require_once("interfaces.inc");
require_once("plugins.inc.d/rfc2136.inc");
if (!isset($config['dnsupdates']['dnsupdate'])) {
$config['dnsupdates']['dnsupdate'] = array();
......@@ -109,23 +111,21 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
}
write_config('New/Edited RFC2136 dnsupdate entry was posted');
system_cron_configure();
if (!empty($pconfig['force'])) {
services_dnsupdate_process("", $rfc2136['host'], true);
} else {
services_dnsupdate_process();
rfc2136_configure_do(false, '', $rfc2136['host'], true);
}
header(url_safe('Location: /services_rfc2136.php'));
exit;
}
}
legacy_html_escape_form_data($pconfig);
include("head.inc");
?>
?>
<body>
<?php include("fbegin.inc"); ?>
<section class="page-content-main">
......@@ -247,12 +247,12 @@ include("head.inc");
<tr>
<td>&nbsp;</td>
<td>
<input name="save" type="submit" class="btn btn-primary" value="<?=gettext("Save");?>" onclick="enable_change(true)" />
<a href="services_rfc2136.php"><input name="Cancel" type="button" class="btn btn-default" value="<?=gettext("Cancel");?>" /></a>
<input name="force" type="submit" class="btn btn-default" value="<?=gettext("Save &amp; Force Update");?>" onclick="enable_change(true)" />
<button name="save" type="submit" class="btn btn-primary" value="save"><?= gettext('Save') ?></button>
<?php if (isset($id)): ?>
<input name="id" type="hidden" value="<?=$id;?>" />
<button name="force" type="submit" class="btn btn-primary" value="force"><?= gettext('Save and Force Update') ?></button>
<input name="id" type="hidden" value="<?=$id;?>" />
<?php endif; ?>
<a href="services_rfc2136.php" class="btn btn-default"><?= gettext('Cancel') ?></a>
</td>
</tr>
<tr>
......
......@@ -87,6 +87,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$retval = system_routing_configure();
configd_run('dyndns reload');
configd_run('rfc2136 reload');
configd_run('ipsecdns reload');
configd_run('filter reload');
......
<?php
$rfc2136_title = gettext('RFC 2136');
$rfc2136_title_link = 'services_rfc2136.php';
......@@ -32,6 +32,7 @@ require_once("guiconfig.inc");
require_once("widgets/include/dyn_dns_status.inc");
require_once("services.inc");
require_once("interfaces.inc");
require_once("plugins.inc.d/dyndns.inc");
if (!isset($config['dyndnses']['dyndns'])) {
$config['dyndnses']['dyndns'] = array();
......@@ -49,22 +50,22 @@ if (!empty($_REQUEST['getdyndnsstatus'])) {
echo '|';
}
$filename = "/conf/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}.cache";
$filename = dyndns_cache_file($dyndns, 4);
$fdata = '';
if (!empty($dyndns['enable']) && file_exists($filename)) {
$ipaddr = dyndnsCheckIP($dyndns['interface']);
$ipaddr = get_dyndns_ip($dyndns['interface'], 4);
$fdata = @file_get_contents($filename);
}
$filename_v6 = "/conf/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}_v6.cache";
$filename_v6 = dyndns_cache_file($dyndns, 6);
$fdata6 = '';
if (!empty($dyndns['enable']) && file_exists($filename_v6)) {
$ipv6addr = get_interface_ipv6($dyndns['interface']);
$ipv6addr = get_dyndns_ip($dyndns['interface'], 6);
$fdata6 = @file_get_contents($filename_v6);
}
if (!empty($fdata)) {
$cached_ip_s = preg_split('/:/', $fdata);
$cached_ip_s = explode('|', $fdata);
$cached_ip = $cached_ip_s[0];
echo sprintf(
'<font color="%s">%s</font>',
......@@ -80,7 +81,7 @@ if (!empty($_REQUEST['getdyndnsstatus'])) {
htmlspecialchars($cached_ipv6)
);
} else {
echo sprintf('<span class="text-muted">%s</span>', gettext('N/A'));
echo gettext('N/A');
}
}
exit;
......@@ -91,7 +92,7 @@ if (!empty($_REQUEST['getdyndnsstatus'])) {
<table class="table table-striped table-condensed">
<thead>
<tr>
<th><?=gettext("Int.");?></th>
<th><?=gettext("Interface");?></th>
<th><?=gettext("Service");?></th>
<th><?=gettext("Hostname");?></th>
<th><?=gettext("Cached IP");?></th>
......@@ -100,55 +101,41 @@ if (!empty($_REQUEST['getdyndnsstatus'])) {
<tbody>
<?php
$iflist = get_configured_interface_with_descr();
$types = services_dyndns_list();
$types = dyndns_list();
$groupslist = return_gateway_groups_array();
foreach ($a_dyndns as $i => $dyndns) :?>
<tr ondblclick="document.location='services_dyndns_edit.php?id=<?=$i;?>'">
<td>
<td <?= isset($dyndns['enable']) ? '' : 'class="text-muted"' ?>>
<?php
foreach ($iflist as $if => $ifdesc) {
if ($dyndns['interface'] == $if) {
if (!isset($dyndns['enable'])) {
echo "<span class=\"text-muted\">{$ifdesc}</span>";
} else {
echo "{$ifdesc}";
}
echo "{$ifdesc}";
break;
}
}
foreach ($groupslist as $if => $group) {
if ($dyndns['interface'] == $if) {
if (!isset($dyndns['enable'])) {
echo "<span class=\"text-muted\">{$if}</span>";
} else {
echo "{$if}";
}
echo "{$if}";
break;
}
}?>
</td>
<td>
<td <?= isset($dyndns['enable']) ? '' : 'class="text-muted"' ?>>
<?php
if (isset($types[$dyndns['type']])) {
if (!isset($dyndns['enable'])) {
echo '<span class="text-muted">' . htmlspecialchars($types[$dyndns['type']]) . '</span>';
} else {
echo htmlspecialchars($types[$dyndns['type']]);
}
}
?>
</td>
<td>
<?php
if (!isset($dyndns['enable'])) {
echo "<span class=\"text-muted\">".htmlspecialchars($dyndns['host'])."</span>";
echo htmlspecialchars($types[$dyndns['type']]);
} else {
echo htmlspecialchars($dyndns['host']);
echo htmlspecialchars($dyndns['type']);
}
?>
</td>
<td>
<div id='dyndnsstatus<?=$i;?>'><?=gettext("Checking ...");?></div>
<td <?= isset($dyndns['enable']) ? '' : 'class="text-muted"' ?>>
<?= htmlspecialchars($dyndns['host']) ?>
</td>
<td <?= isset($dyndns['enable']) ? '' : 'class="text-muted"' ?>>
<div id='dyndnsstatus<?=$i;?>'>
<?= gettext('Checking...') ?>
</div>
</td>
</tr>
<?php
......
<?php
/*
Copyright (C) 2017 Franco Fichtner <franco@opnsense.org>
Copyright (C) 2014-2016 Deciso B.V.
Copyright (C) 2008 Ermal Luci
Copyright (C) 2013 Stanley P. Miller \ stan-qaz
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INClUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
require_once("guiconfig.inc");
require_once("widgets/include/rfc2136.inc");
require_once("services.inc");
require_once("interfaces.inc");
require_once("plugins.inc.d/rfc2136.inc");
if (!isset($config['dnsupdates']['dnsupdate'])) {
$config['dnsupdates']['dnsupdate'] = array();
}
$a_rfc2136 = &$config['dnsupdates']['dnsupdate'];
if (!empty($_REQUEST['getrfc2136status'])) {
$first_entry = true;
foreach ($a_rfc2136 as $rfc2136) {
if ($first_entry) {
$first_entry = false;
} else {
// Put a vertical bar delimiter between the echoed HTML for each entry processed.
echo '|';
}
$filename = rfc2136_cache_file($rfc2136, 4);
$fdata = '';
if (!empty($rfc2136['enable']) && (empty($rfc2136['recordtype']) || $rfc2136['recordtype'] == 'A') && file_exists($filename)) {
$ipaddr = get_dyndns_ip($rfc2136['interface'], 4);
$fdata = @file_get_contents($filename);
}
$filename_v6 = rfc2136_cache_file($rfc2136, 6);
$fdata6 = '';
if (!empty($rfc2136['enable']) && (empty($rfc2136['recordtype']) || $rfc2136['recordtype'] == 'AAAA') && file_exists($filename_v6)) {
$ipv6addr = get_dyndns_ip($rfc2136['interface'], 6);
$fdata6 = @file_get_contents($filename_v6);
}
if (!empty($fdata)) {
$cached_ip_s = explode('|', $fdata);
$cached_ip = $cached_ip_s[0];
echo sprintf(
'IPv4: <font color="%s">%s</font>',
$ipaddr != $cached_ip ? 'red' : 'green',
htmlspecialchars($cached_ip)
);
} else {
echo 'IPv4: ' . gettext('N/A');
}
echo '<br />';
if (!empty($fdata6)) {
$cached_ipv6_s = explode('|', $fdata6);
$cached_ipv6 = $cached_ipv6_s[0];
echo sprintf(
'IPv6: <font color="%s">%s</font>',
$ipv6addr != $cached_ipv6 ? 'red' : 'green',
htmlspecialchars($cached_ipv6)
);
} else {
echo 'IPv6: ' . gettext('N/A');
}
}
exit;
}
?>
<table class="table table-striped table-condensed">
<thead>
<tr>
<th><?=gettext("Interface");?></th>
<th><?=gettext("Server");?></th>
<th><?=gettext("Hostname");?></th>
<th><?=gettext("Cached IP");?></th>
</tr>
</thead>
<tbody>
<?php
$iflist = get_configured_interface_with_descr();
$groupslist = return_gateway_groups_array();
foreach ($a_rfc2136 as $i => $rfc2136) :?>
<tr ondblclick="document.location='services_rfc2136_edit.php?id=<?=$i;?>'">
<td <?= isset($rfc2136['enable']) ? '' : 'class="text-muted"' ?>>
<?php
foreach ($iflist as $if => $ifdesc) {
if ($rfc2136['interface'] == $if) {
echo "{$ifdesc}";
break;
}
}
foreach ($groupslist as $if => $group) {
if ($rfc2136['interface'] == $if) {
echo "{$if}";
break;
}
}?>
</td>
<td <?= isset($rfc2136['enable']) ? '' : 'class="text-muted"' ?>>
<?= htmlspecialchars($rfc2136['server']) ?>
</td>
<td <?= isset($rfc2136['enable']) ? '' : 'class="text-muted"' ?>>
<?= htmlspecialchars($rfc2136['host']) ?>
</td>
<td <?= isset($rfc2136['enable']) ? '' : 'class="text-muted"' ?>>
<div id='rfc2136status<?=$i;?>'>
<?= gettext('Checking...') ?>
</div>
</td>
</tr>
<?php
endforeach;?>
</tbody>
</table>
<script type="text/javascript">
function rfc2136_getstatus()
{
scroll(0,0);
var url = "/widgets/widgets/rfc2136.widget.php";
var pars = 'getrfc2136status=yes';
jQuery.ajax(url, {type: 'get', data: pars, complete: rfc2136callback});
// Refresh the status every 5 minutes
setTimeout('rfc2136_getstatus()', 5*60*1000);
}
function rfc2136callback(transport)
{
// The server returns a string of statuses separated by vertical bars
var responseStrings = transport.responseText.split("|");
for (var count=0; count<responseStrings.length; count++) {
var divlabel = '#rfc2136status' + count;
jQuery(divlabel).prop('innerHTML',responseStrings[count]);
}
}
$( document ).ready(function() {
// Do the first status check 2 seconds after the dashboard opens
setTimeout('rfc2136_getstatus()', 2000);
});
</script>
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