mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 00:07:26 +00:00
rfc2136: move to plugins
This commit is contained in:
parent
59200fb2df
commit
7884e3456e
2
Makefile
2
Makefile
@ -43,7 +43,6 @@ CORE_HASH= ${CORE_COMMIT:C/^.*-//1}
|
||||
|
||||
CORE_ABI?= 17.1
|
||||
CORE_ARCH?= ${ARCH}
|
||||
CORE_BIND?= 911
|
||||
CORE_OPENVPN?= # empty for version 2.4
|
||||
CORE_PHP?= 71
|
||||
CORE_PY?= 27
|
||||
@ -73,7 +72,6 @@ CORE_WWW?= https://opnsense.org/
|
||||
CORE_DEPENDS_amd64?= beep bsdinstaller
|
||||
CORE_DEPENDS_i386?= ${CORE_DEPENDS_amd64}
|
||||
CORE_DEPENDS?= apinger \
|
||||
bind${CORE_BIND} \
|
||||
ca_root_nss \
|
||||
choparp \
|
||||
cpustats \
|
||||
|
||||
9
plist
9
plist
@ -47,7 +47,6 @@
|
||||
/usr/local/etc/inc/plugins.inc.d/openvpn/tls-verify.php
|
||||
/usr/local/etc/inc/plugins.inc.d/openvpn/wizard.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
|
||||
@ -127,7 +126,6 @@
|
||||
/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
|
||||
@ -470,8 +468,6 @@
|
||||
/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
|
||||
@ -657,7 +653,6 @@
|
||||
/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
|
||||
@ -1071,8 +1066,6 @@
|
||||
/usr/local/www/services_ntpd_gps.php
|
||||
/usr/local/www/services_ntpd_pps.php
|
||||
/usr/local/www/services_opendns.php
|
||||
/usr/local/www/services_rfc2136.php
|
||||
/usr/local/www/services_rfc2136_edit.php
|
||||
/usr/local/www/services_router_advertisements.php
|
||||
/usr/local/www/services_unbound.php
|
||||
/usr/local/www/services_unbound_acls.php
|
||||
@ -1144,7 +1137,6 @@
|
||||
/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
|
||||
@ -1159,7 +1151,6 @@
|
||||
/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
|
||||
|
||||
@ -1,248 +0,0 @@
|
||||
<?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'),
|
||||
'newwanip' => 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";
|
||||
}
|
||||
}
|
||||
@ -47,7 +47,6 @@ require_once('plugins.inc.d/dnsmasq.inc');
|
||||
require_once('plugins.inc.d/dyndns.inc');
|
||||
require_once('plugins.inc.d/ipsec.inc');
|
||||
require_once('plugins.inc.d/openvpn.inc');
|
||||
require_once('plugins.inc.d/rfc2136.inc');
|
||||
require_once('plugins.inc.d/openssh.inc');
|
||||
require_once('plugins.inc.d/unbound.inc');
|
||||
|
||||
|
||||
@ -1,51 +0,0 @@
|
||||
#!/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);
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
<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>
|
||||
@ -1,7 +0,0 @@
|
||||
<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>
|
||||
@ -1,6 +0,0 @@
|
||||
[reload]
|
||||
command:/usr/local/etc/rc.rfc2136
|
||||
description:RFC 2136 Update
|
||||
parameters:%s
|
||||
type:script
|
||||
message:updating rfc2136 %s
|
||||
@ -1,212 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
Copyright (C) 2014-2015 Deciso B.V.
|
||||
Copyright (C) 2008 Ermal Luçi
|
||||
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("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();
|
||||
}
|
||||
|
||||
$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();
|
||||
system_cron_configure();
|
||||
}
|
||||
exit;
|
||||
} elseif (isset($_POST['act']) && $_POST['act'] == "toggle" && isset($_POST['id'])) {
|
||||
if (!empty($a_rfc2136[$_POST['id']])) {
|
||||
if (!empty($a_rfc2136[$_POST['id']]['enable'])) {
|
||||
$a_rfc2136[$_POST['id']]['enable'] = false;
|
||||
} else {
|
||||
$a_rfc2136[$_POST['id']]['enable'] = true;
|
||||
}
|
||||
write_config();
|
||||
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() {
|
||||
// delete service action
|
||||
$(".act_delete_service").click(function(event){
|
||||
event.preventDefault();
|
||||
var id = $(this).data("id");
|
||||
BootstrapDialog.show({
|
||||
type:BootstrapDialog.TYPE_DANGER,
|
||||
title: "<?= gettext("RFC 2136");?>",
|
||||
message: "<?=gettext("Do you really want to delete this client?");?>",
|
||||
buttons: [{
|
||||
label: "<?= gettext("No");?>",
|
||||
action: function(dialogRef) {
|
||||
dialogRef.close();
|
||||
}}, {
|
||||
label: "<?= gettext("Yes");?>",
|
||||
action: function(dialogRef) {
|
||||
$.post(window.location, {act: 'del', id:id}, function(data) {
|
||||
location.reload();
|
||||
});
|
||||
}
|
||||
}]
|
||||
});
|
||||
});
|
||||
// link toggle buttons
|
||||
$(".act_toggle").click(function(event){
|
||||
event.preventDefault();
|
||||
$.post(window.location, {act: 'toggle', id:$(this).data("id")}, function(data) {
|
||||
location.reload();
|
||||
});
|
||||
});
|
||||
// watch scroll position and set to last known on page load
|
||||
watchScrollPosition();
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php include("fbegin.inc"); ?>
|
||||
<section class="page-content-main">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<?php if (isset($input_errors) && count($input_errors) > 0) print_input_errors($input_errors); ?>
|
||||
<section class="col-xs-12">
|
||||
<div class="tab-content content-box col-xs-12">
|
||||
<form method="post" name="iform" id="iform">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?=gettext("If");?></th>
|
||||
<th><?=gettext("Server");?></th>
|
||||
<th><?=gettext("Hostname");?></th>
|
||||
<th><?=gettext("Cached IP");?></th>
|
||||
<th><?=gettext("Description");?></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach ($a_rfc2136 as $rfc2136): ?>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="#" class="act_toggle" data-id="<?=$i;?>" data-toggle="tooltip" title="<?=(!empty($rfc2136['enable'])) ? gettext("disable") : gettext("enable");?>">
|
||||
<span class="glyphicon glyphicon-play <?=(!empty($rfc2136['enable'])) ? "text-success" : "text-muted";?>"></span>
|
||||
</a>
|
||||
<?=!empty($config['interfaces'][$rfc2136['interface']]['descr']) ? $config['interfaces'][$rfc2136['interface']]['descr'] : strtoupper($rfc2136['interface']);?>
|
||||
</td>
|
||||
<td><?=$rfc2136['server'];?></td>
|
||||
<td><?=$rfc2136['host'];?></td>
|
||||
<td>
|
||||
<?php
|
||||
$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 = get_dyndns_ip($rfc2136['interface'], 4);
|
||||
} else {
|
||||
$ipaddr = get_interface_ip($rfc2136['interface']);
|
||||
}
|
||||
$cached_ip_s = explode("|", file_get_contents($filename));
|
||||
$cached_ip = $cached_ip_s[0];
|
||||
if ($ipaddr <> $cached_ip) {
|
||||
echo "<font color='red'>";
|
||||
} else {
|
||||
echo "<font color='green'>";
|
||||
}
|
||||
echo htmlspecialchars($cached_ip);
|
||||
echo "</font>";
|
||||
} else {
|
||||
echo 'IPv4: ' . gettext('N/A');
|
||||
}
|
||||
echo "<br />";
|
||||
$filename6 = rfc2136_cache_file($rfc2136, 6);
|
||||
if (file_exists($filename6) && !empty($rfc2136['enable']) && (empty($rfc2136['recordtype']) || $rfc2136['recordtype'] == 'AAAA')) {
|
||||
echo "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'>";
|
||||
} else {
|
||||
echo "<font color='green'>";
|
||||
}
|
||||
echo htmlspecialchars($cached_ip);
|
||||
echo "</font>";
|
||||
} else {
|
||||
echo 'IPv6: ' . gettext('N/A');
|
||||
}?>
|
||||
</td>
|
||||
<td><?=$rfc2136['descr'];?></td>
|
||||
<td>
|
||||
<a href="services_rfc2136_edit.php?id=<?=$i;?>">
|
||||
<button type="button" class="btn btn-xs btn-default"><span class="fa fa-pencil"></span></button>
|
||||
</a>
|
||||
<a href="#" data-id="<?=$i;?>" class="act_delete_service"><button type="button" class="btn btn-xs btn-default"><span class="fa fa-trash text-muted"></span></button></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
$i++;
|
||||
endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<?php include("foot.inc"); ?>
|
||||
@ -1,273 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
Copyright (C) 2014-2016 Deciso B.V.
|
||||
Copyright (C) 2008 Ermal Luçi
|
||||
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("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();
|
||||
}
|
||||
$a_rfc2136 = &$config['dnsupdates']['dnsupdate'];
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
if (isset($_GET['id']) && !empty($a_rfc2136[$_GET['id']])) {
|
||||
$id = $_GET['id'];
|
||||
}
|
||||
|
||||
if (isset($id)) {
|
||||
$pconfig['enable'] = isset($a_rfc2136[$id]['enable']);
|
||||
} else {
|
||||
$pconfig['enable'] = true;
|
||||
}
|
||||
|
||||
$pconfig['host'] = isset($id) && !empty($a_rfc2136[$id]['host']) ? $a_rfc2136[$id]['host'] : null;
|
||||
$pconfig['ttl'] = isset($id) &&!empty($a_rfc2136[$id]['ttl']) ? $a_rfc2136[$id]['ttl'] : 60;
|
||||
$pconfig['keydata'] = isset($id) &&!empty($a_rfc2136[$id]['keydata']) ? $a_rfc2136[$id]['keydata'] : null;
|
||||
$pconfig['keyname'] = isset($id) &&!empty($a_rfc2136[$id]['keyname']) ? $a_rfc2136[$id]['keyname'] : null;
|
||||
$pconfig['keytype'] = isset($id) &&!empty($a_rfc2136[$id]['keytype']) ? $a_rfc2136[$id]['keytype'] : "zone";
|
||||
$pconfig['server'] = isset($id) &&!empty($a_rfc2136[$id]['server']) ? $a_rfc2136[$id]['server'] : null;
|
||||
$pconfig['interface'] = isset($id) &&!empty($a_rfc2136[$id]['interface']) ? $a_rfc2136[$id]['interface'] : null;
|
||||
$pconfig['descr'] = isset($id) &&!empty($a_rfc2136[$id]['descr']) ? $a_rfc2136[$id]['descr'] : null;
|
||||
$pconfig['recordtype'] = isset($id) && !empty($a_rfc2136[$id]['recordtype']) ? $a_rfc2136[$id]['recordtype'] : null;
|
||||
|
||||
$pconfig['usetcp'] = isset($a_rfc2136[$id]['usetcp']);
|
||||
$pconfig['usepublicip'] = isset($a_rfc2136[$id]['usepublicip']);
|
||||
|
||||
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if (isset($_POST['id']) && !empty($a_rfc2136[$_POST['id']])) {
|
||||
$id = $_POST['id'];
|
||||
}
|
||||
$input_errors = array();
|
||||
$pconfig = $_POST;
|
||||
/* input validation */
|
||||
$reqdfields = array();
|
||||
$reqdfieldsn = array();
|
||||
$reqdfields = array_merge($reqdfields, explode(" ", "host ttl keyname keydata"));
|
||||
$reqdfieldsn = array_merge($reqdfieldsn, array(gettext("Hostname"), gettext("TTL"), gettext("Key name"), gettext("Key")));
|
||||
|
||||
do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors);
|
||||
|
||||
if (!empty($pconfig['host']) && !is_domain($pconfig['host'])) {
|
||||
$input_errors[] = gettext("The DNS update host name contains invalid characters.");
|
||||
}
|
||||
if (!empty($pconfig['ttl']) && !is_numericint($pconfig['ttl'])) {
|
||||
$input_errors[] = gettext("The DNS update TTL must be an integer.");
|
||||
}
|
||||
if (!empty($pconfig['keyname']) && !is_domain($pconfig['keyname'])) {
|
||||
$input_errors[] = gettext("The DNS update key name contains invalid characters.");
|
||||
}
|
||||
|
||||
if (count($input_errors) == 0) {
|
||||
$rfc2136 = array();
|
||||
$rfc2136['enable'] = !empty($pconfig['enable']);
|
||||
$rfc2136['host'] = $pconfig['host'];
|
||||
$rfc2136['ttl'] = $pconfig['ttl'];
|
||||
$rfc2136['keyname'] = $pconfig['keyname'];
|
||||
$rfc2136['keytype'] = $pconfig['keytype'];
|
||||
$rfc2136['keydata'] = $pconfig['keydata'];
|
||||
$rfc2136['server'] = $pconfig['server'];
|
||||
$rfc2136['usetcp'] = !empty($pconfig['usetcp']);
|
||||
$rfc2136['usepublicip'] = !empty($pconfig['usepublicip']);
|
||||
$rfc2136['interface'] = $pconfig['interface'];
|
||||
$rfc2136['descr'] = $pconfig['descr'];
|
||||
|
||||
if (!empty($pconfig['recordtype'])) {
|
||||
$rfc2136['recordtype'] = $pconfig['recordtype'];
|
||||
}
|
||||
|
||||
if (isset($id)) {
|
||||
$a_rfc2136[$id] = $rfc2136;
|
||||
} else {
|
||||
$a_rfc2136[] = $rfc2136;
|
||||
}
|
||||
|
||||
write_config('New/Edited RFC2136 dnsupdate entry was posted');
|
||||
system_cron_configure();
|
||||
|
||||
if (!empty($pconfig['force'])) {
|
||||
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">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<?php if (isset($input_errors) && count($input_errors) > 0) print_input_errors($input_errors); ?>
|
||||
<?php if (isset($savemsg)) print_info_box($savemsg); ?>
|
||||
<section class="col-xs-12">
|
||||
<div class="content-box">
|
||||
<form method="post" name="iform" id="iform">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped opnsense_standard_table_form">
|
||||
<tr>
|
||||
<td width="22%"><strong><?=gettext("RFC 2136 client");?></strong></td>
|
||||
<td width="78%" align="right">
|
||||
<small><?=gettext("full help"); ?> </small>
|
||||
<i class="fa fa-toggle-off text-danger" style="cursor: pointer;" id="show_all_help_page" type="button"></i>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Enable");?></td>
|
||||
<td>
|
||||
<input name="enable" type="checkbox" id="enable" value="yes" <?=!empty($pconfig['enable']) ? "checked=\"checked\"" : ""; ?> />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Interface to monitor");?></td>
|
||||
<td>
|
||||
<select name="interface" class="selectpicker" id="requestif">
|
||||
<?php
|
||||
foreach (get_configured_interface_with_descr() as $if => $ifdesc):?>
|
||||
<option value="<?=$if;?>" <?=$pconfig['interface'] == $if ? "selected=\"selected\"" : "";?>>
|
||||
<?=htmlspecialchars($ifdesc);?>
|
||||
</option>
|
||||
|
||||
<?php
|
||||
endforeach;?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_host" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Hostname");?></td>
|
||||
<td>
|
||||
<input name="host" type="text" id="host" value="<?=$pconfig['host'];?>" />
|
||||
<div class="hidden" for="help_for_host">
|
||||
<?= gettext('Fully qualified hostname of the host to be updated.') ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_recordtype" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Record Type");?></td>
|
||||
<td>
|
||||
<input name="recordtype" type="radio" value="" <?= empty($pconfig['recordtype']) ? 'checked="checked"' : '' ?> /> <?=gettext('All');?>
|
||||
<input name="recordtype" type="radio" value="A" <?= $pconfig['recordtype'] == 'A' ? 'checked="checked"' : '' ?> /> <?=gettext('A (IPv4)');?>
|
||||
<input name="recordtype" type="radio" value="AAAA" <?= $pconfig['recordtype'] == 'AAAA' ? 'checked="checked"' : '' ?> /> <?=gettext('AAAA (IPv6)');?>
|
||||
<div class="hidden" for="help_for_recordtype">
|
||||
<?=gettext("'All' will update all available record types.");?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("TTL"); ?> (<?=gettext("seconds");?>)</td>
|
||||
<td>
|
||||
<input name="ttl" type="text" id="ttl" value="<?=$pconfig['ttl'];?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_keyname" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Key name");?></td>
|
||||
<td>
|
||||
<input name="keyname" type="text" id="keyname" value="<?=$pconfig['keyname'];?>" />
|
||||
<div class="hidden" for="help_for_keyname">
|
||||
<?=gettext("This must match the setting on the DNS server.");?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Key type");?> </td>
|
||||
<td>
|
||||
<input name="keytype" type="radio" value="zone" <?= $pconfig['keytype'] == "zone" ? "checked=\"checked\"" :""; ?> /> <?=gettext("Zone");?>
|
||||
<input name="keytype" type="radio" value="host" <?= $pconfig['keytype'] == "host" ? "checked=\"checked\"" :""; ?> /> <?=gettext("Host");?>
|
||||
<input name="keytype" type="radio" value="user" <?= $pconfig['keytype'] == "user" ? "checked=\"checked\"" :""; ?> /> <?=gettext("User");?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_keydata" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Key");?></td>
|
||||
<td>
|
||||
<input name="keydata" type="text" id="keydata" size="70" value="<?=htmlspecialchars($pconfig['keydata']);?>" />
|
||||
<div class="hidden" for="help_for_keydata">
|
||||
<?=gettext("Paste an HMAC-MD5 key here.");?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Server");?></td>
|
||||
<td>
|
||||
<input name="server" type="text" class="formfld" id="server" size="30" value="<?=$pconfig['server'];?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Protocol");?></td>
|
||||
<td>
|
||||
<input name="usetcp" type="checkbox" id="usetcp" value="<?=gettext("yes");?>" <?=!empty($pconfig['usetcp']) ? "checked=\"checked\"" : ""; ?> />
|
||||
<strong><?=gettext("Use TCP instead of UDP");?></strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Use Public IP");?></td>
|
||||
<td>
|
||||
<input name="usepublicip" type="checkbox" id="usepublicip" value="<?=gettext("yes");?>" <?=!empty($pconfig['usepublicip']) ? "checked=\"checked\"" : ""; ?> />
|
||||
<strong><?=gettext("If the interface IP is private, attempt to fetch and use the public IP instead.");?></strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?=gettext("Description");?></td>
|
||||
<td>
|
||||
<input name="descr" type="text" id="descr" value="<?=$pconfig['descr'];?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>
|
||||
<button name="save" 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;?>" />
|
||||
<?php endif; ?>
|
||||
<a href="services_rfc2136.php" class="btn btn-default"><?= gettext('Cancel') ?></a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<?= sprintf(gettext("You must configure a DNS server in %sSystem: " .
|
||||
"General setup%s or allow the DNS server list to be overridden " .
|
||||
"by DHCP/PPP on WAN for dynamic DNS updates to work."),'<a href="system_general.php">', '</a>');?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<?php include("foot.inc"); ?>
|
||||
@ -1,4 +0,0 @@
|
||||
<?php
|
||||
|
||||
$rfc2136_title = gettext('RFC 2136');
|
||||
$rfc2136_title_link = 'services_rfc2136.php';
|
||||
@ -1,168 +0,0 @@
|
||||
<?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>
|
||||
Loading…
x
Reference in New Issue
Block a user