Commit 7884e345 authored by Franco Fichtner's avatar Franco Fichtner

rfc2136: move to plugins

parent 59200fb2
...@@ -43,7 +43,6 @@ CORE_HASH= ${CORE_COMMIT:C/^.*-//1} ...@@ -43,7 +43,6 @@ CORE_HASH= ${CORE_COMMIT:C/^.*-//1}
CORE_ABI?= 17.1 CORE_ABI?= 17.1
CORE_ARCH?= ${ARCH} CORE_ARCH?= ${ARCH}
CORE_BIND?= 911
CORE_OPENVPN?= # empty for version 2.4 CORE_OPENVPN?= # empty for version 2.4
CORE_PHP?= 71 CORE_PHP?= 71
CORE_PY?= 27 CORE_PY?= 27
...@@ -73,7 +72,6 @@ CORE_WWW?= https://opnsense.org/ ...@@ -73,7 +72,6 @@ CORE_WWW?= https://opnsense.org/
CORE_DEPENDS_amd64?= beep bsdinstaller CORE_DEPENDS_amd64?= beep bsdinstaller
CORE_DEPENDS_i386?= ${CORE_DEPENDS_amd64} CORE_DEPENDS_i386?= ${CORE_DEPENDS_amd64}
CORE_DEPENDS?= apinger \ CORE_DEPENDS?= apinger \
bind${CORE_BIND} \
ca_root_nss \ ca_root_nss \
choparp \ choparp \
cpustats \ cpustats \
......
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
/usr/local/etc/inc/plugins.inc.d/openvpn/tls-verify.php /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/openvpn/wizard.inc
/usr/local/etc/inc/plugins.inc.d/pf.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.inc
/usr/local/etc/inc/plugins.inc.d/squid/auth-user.php /usr/local/etc/inc/plugins.inc.d/squid/auth-user.php
/usr/local/etc/inc/plugins.inc.d/suricata.inc /usr/local/etc/inc/plugins.inc.d/suricata.inc
...@@ -127,7 +126,6 @@ ...@@ -127,7 +126,6 @@
/usr/local/etc/rc.reload_interfaces /usr/local/etc/rc.reload_interfaces
/usr/local/etc/rc.resolv_conf_generate /usr/local/etc/rc.resolv_conf_generate
/usr/local/etc/rc.restart_webgui /usr/local/etc/rc.restart_webgui
/usr/local/etc/rc.rfc2136
/usr/local/etc/rc.shutdown /usr/local/etc/rc.shutdown
/usr/local/etc/rc.sshd /usr/local/etc/rc.sshd
/usr/local/etc/rc.syshook /usr/local/etc/rc.syshook
...@@ -470,8 +468,6 @@ ...@@ -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/Migrations/M1_0_0.php
/usr/local/opnsense/mvc/app/models/OPNsense/Proxy/Proxy.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/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/ACL/ACL.xml
/usr/local/opnsense/mvc/app/models/OPNsense/TrafficShaper/Menu/Menu.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 /usr/local/opnsense/mvc/app/models/OPNsense/TrafficShaper/Migrations/M1_0_0.php
...@@ -657,7 +653,6 @@ ...@@ -657,7 +653,6 @@
/usr/local/opnsense/service/conf/actions.d/actions_openssh.conf /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_openvpn.conf
/usr/local/opnsense/service/conf/actions.d/actions_proxy.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_routedns.conf
/usr/local/opnsense/service/conf/actions.d/actions_system.conf /usr/local/opnsense/service/conf/actions.d/actions_system.conf
/usr/local/opnsense/service/conf/actions.d/actions_systemhealth.conf /usr/local/opnsense/service/conf/actions.d/actions_systemhealth.conf
...@@ -1071,8 +1066,6 @@ ...@@ -1071,8 +1066,6 @@
/usr/local/www/services_ntpd_gps.php /usr/local/www/services_ntpd_gps.php
/usr/local/www/services_ntpd_pps.php /usr/local/www/services_ntpd_pps.php
/usr/local/www/services_opendns.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_router_advertisements.php
/usr/local/www/services_unbound.php /usr/local/www/services_unbound.php
/usr/local/www/services_unbound_acls.php /usr/local/www/services_unbound_acls.php
...@@ -1144,7 +1137,6 @@ ...@@ -1144,7 +1137,6 @@
/usr/local/www/widgets/include/log.inc /usr/local/www/widgets/include/log.inc
/usr/local/www/widgets/include/ntp_status.inc /usr/local/www/widgets/include/ntp_status.inc
/usr/local/www/widgets/include/openvpn.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/services_status.inc
/usr/local/www/widgets/include/system_log.inc /usr/local/www/widgets/include/system_log.inc
/usr/local/www/widgets/include/thermal_sensors.inc /usr/local/www/widgets/include/thermal_sensors.inc
...@@ -1159,7 +1151,6 @@ ...@@ -1159,7 +1151,6 @@
/usr/local/www/widgets/widgets/ntp_status.widget.php /usr/local/www/widgets/widgets/ntp_status.widget.php
/usr/local/www/widgets/widgets/openvpn.widget.php /usr/local/www/widgets/widgets/openvpn.widget.php
/usr/local/www/widgets/widgets/picture.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/rss.widget.php
/usr/local/www/widgets/widgets/services_status.widget.php /usr/local/www/widgets/widgets/services_status.widget.php
/usr/local/www/widgets/widgets/system_information.widget.php /usr/local/www/widgets/widgets/system_information.widget.php
......
<?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'); ...@@ -47,7 +47,6 @@ require_once('plugins.inc.d/dnsmasq.inc');
require_once('plugins.inc.d/dyndns.inc'); require_once('plugins.inc.d/dyndns.inc');
require_once('plugins.inc.d/ipsec.inc'); require_once('plugins.inc.d/ipsec.inc');
require_once('plugins.inc.d/openvpn.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/openssh.inc');
require_once('plugins.inc.d/unbound.inc'); require_once('plugins.inc.d/unbound.inc');
......
#!/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);
}
<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.rfc2136
description:RFC 2136 Update
parameters:%s
type:script
message:updating rfc2136 %s
<?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"); ?>
This diff is collapsed.
<?php
$rfc2136_title = gettext('RFC 2136');
$rfc2136_title_link = 'services_rfc2136.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