Commit 26032f66 authored by Franco Fichtner's avatar Franco Fichtner

services: more work on dynamic dns and rfc 2136

parent d51dd4ad
......@@ -35,7 +35,7 @@
/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/phpdns.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/ipfw.inc
/usr/local/etc/inc/plugins.inc.d/ipsec.inc
......
......@@ -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
}
......
......@@ -29,7 +29,7 @@
POSSIBILITY OF SUCH DAMAGE.
*/
require_once('plugins.inc.d/dyndns/phpdns.inc');
require_once('plugins.inc.d/dyndns/phpDynDNS.inc');
require_once('plugins.inc.d/dyndns/r53.inc');
function dyndns_configure()
......@@ -56,6 +56,26 @@ function dyndns_enabled()
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();
......
......@@ -147,7 +147,7 @@
$this->_curlSslVerifypeer = $curlSslVerifypeer;
$this->_dnsVerboseLog = $dnsVerboseLog;
if ($this->_dnsVerboseLog)
log_error("DynDns: updatedns() starting");
log_error("Dynamic DNS: updatedns() starting");
$dyndnslck = lock("DDNS".$dnsID, LOCK_EX);
......@@ -279,7 +279,7 @@
function _update() {
if ($this->_dnsVerboseLog)
log_error("Dynamic DNS ({$this->_dnsHost}): DynDns _update() starting.");
log_error("Dynamic DNS ({$this->_dnsHost}): _update() starting.");
if ($this->_dnsService != 'ods' and $this->_dnsService != 'route53 ') {
$ch = curl_init();
......@@ -649,7 +649,7 @@
break;
case 'eurodns':
if ($this->_dnsVerboseLog)
log_error("EuroDynDns ({$this->_dnsHost}) DNS update() starting.");
log_error("EuroDNS ({$this->_dnsHost}) DNS update() starting.");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_USERPWD, $this->_dnsUser.':'.$this->_dnsPass);
$server = "https://eurodyndns.org/update/";
......@@ -729,7 +729,7 @@
*/
function _checkStatus($ch, $data) {
if ($this->_dnsVerboseLog) {
log_error("Dynamic DNS ({$this->_dnsHost}): DynDns _checkStatus() starting.");
log_error("Dynamic DNS ({$this->_dnsHost}): _checkStatus() starting.");
log_error("Dynamic DNS ({$this->_dnsHost}): Current Service: {$this->_dnsService}");
}
$successful_update = false;
......@@ -981,7 +981,7 @@
break;
case 'dnsexit':
if (preg_match("/is the same/i", $data)) {
$status = "phpDynDns ({$this->_dnsHost}): (Success) No Change In IP Address";
$status = "Dynamic DNS ({$this->_dnsHost}): (Success) No Change In IP Address";
$successful_update = true;
} else if (preg_match("/Success/i", $data)) {
$status = "Dynamic DNS ({$this->_dnsHost}): (Success) IP Address Changed Successfully!";
......@@ -1019,7 +1019,7 @@
} else if (preg_match('/yours/i', $data)) {
$status = "Dynamic DNS ({$this->_dnsHost}): (Error) hostname specified exists, but not under the username specified.";
} else if (preg_match('/abuse/i', $data)) {
$status = "phpDynDns ({$this->_dnsHost}): (Error) Updating too frequently, considered abuse.";
$status = "Dynamic DNS ({$this->_dnsHost}): (Error) Updating too frequently, considered abuse.";
} else {
$status = "Dynamic DNS ({$this->_dnsHost}): (Unknown Response)";
log_error("Dynamic DNS ({$this->_dnsHost}): PAYLOAD: {$data}");
......@@ -1323,10 +1323,10 @@
$wan_ip = $this->_checkIP();
if ($wan_ip == 0) {
log_error("DynDns ({$this->_dnsHost}): Current WAN IP could not be determined, skipping update process.");
log_error("Dynamic DNS ({$this->_dnsHost}): Current WAN IP could not be determined, skipping update process.");
return false;
}
$log_error = "DynDns ({$this->_dnsHost}): Current WAN IP: {$wan_ip} ";
$log_error = "Dynamic DNS ({$this->_dnsHost}): Current WAN IP: {$wan_ip} ";
if ($this->_useIPv6 == true) {
if (file_exists($this->_cacheFile_v6)) {
......@@ -1367,13 +1367,13 @@
/* lets determine if the item needs updating */
if ($cacheIP != $wan_ip) {
$needs_updating = true;
$update_reason = "DynDns: cacheIP != wan_ip. Updating. ";
$update_reason = "Dynamic DNS: cacheIP != wan_ip. Updating. ";
$update_reason .= "Cached IP: {$cacheIP} WAN IP: {$wan_ip} ";
}
if (($currentTime - $cacheTime) > $maxCacheAgeSecs) {
$needs_updating = true;
$this->_forceUpdateNeeded = true;
$update_reason = "DynDns: More than " . $this->_dnsMaxCacheAgeDays . " days. Updating. ";
$update_reason = "Dynamic DNS: More than " . $this->_dnsMaxCacheAgeDays . " days. Updating. ";
$update_reason .= "{$currentTime} - {$cacheTime} > {$maxCacheAgeSecs} ";
}
if ($initial == true) {
......@@ -1386,7 +1386,7 @@
*/
if ($needs_updating == true) {
if ($this->_dnsVerboseLog)
log_error("DynDns ({$this->_dnsHost}): {$update_reason}");
log_error("Dynamic DNS ({$this->_dnsHost}): {$update_reason}");
return true;
}
......@@ -1425,7 +1425,7 @@
$try++;
}
if ($try >= 3) {
log_error("Dyndns debug information ({$this->_dnsHost}): Could not resolve {$hosttocheck} to ip using interface ip {$ip_address}.");
log_error("Dynamic DNS debug information ({$this->_dnsHost}): Could not resolve {$hosttocheck} to ip using interface ip {$ip_address}.");
return 0;
}
$ip_ch = curl_init("http://{$checkip}");
......@@ -1444,14 +1444,14 @@
$ip_address = trim($matches[1]);
if (is_ipaddr($ip_address)) {
if ($this->_dnsVerboseLog)
log_error("DynDns ({$this->_dnsHost}): {$ip_address} extracted from {$hosttocheck}");
log_error("Dynamic DNS ({$this->_dnsHost}): {$ip_address} extracted from {$hosttocheck}");
} else {
log_error("DynDns ({$this->_dnsHost}): IP address could not be extracted from {$hosttocheck}");
log_error("Dynamic DNS ({$this->_dnsHost}): IP address could not be extracted from {$hosttocheck}");
return 0;
}
} else {
if ($this->_dnsVerboseLog)
log_error("DynDns ({$this->_dnsHost}): {$ip_address} extracted from local system.");
log_error("Dynamic DNS ({$this->_dnsHost}): {$ip_address} extracted from local system.");
}
$this->_dnsIP = $ip_address;
......
......@@ -38,8 +38,6 @@ function pf_services()
'description' => gettext('Packet Filter'),
'configd' => array(
'restart' => array('filter reload'),
'start' => array('filter reload'),
'stop' => array('filter reload'),
),
'nocheck' => true,
'name' => 'pf',
......
......@@ -53,6 +53,26 @@ function rfc2136_enabled()
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();
......
......@@ -1295,8 +1295,8 @@ function upgrade_046_to_047() {
}
}
function upgrade_047_to_048() {
function upgrade_047_to_048()
{
global $config;
if (!empty($config['dyndns'])) {
$config['dyndnses'] = array();
......@@ -1311,7 +1311,7 @@ function upgrade_047_to_048() {
$tempdyn['host'] = $config['dyndns'][0]['host'];
$tempdyn['mx'] = $config['dyndns'][0]['mx'];
$tempdyn['interface'] = "wan";
$tempdyn['descr'] = sprintf('Upgraded Dyndns %s', $tempdyn['type']);
$tempdyn['descr'] = sprintf('Upgraded dynamic DNS %s', $tempdyn['type']);
$config['dyndnses']['dyndns'][] = $tempdyn;
}
unset($config['dyndns']);
......
......@@ -246,9 +246,9 @@
</ACL>
</DNSResolver>
<DNSTools VisibleName="DNS Tools" cssClass="fa fa-tags fa-fw">
<DynDNS order="10" url="/services_dyndns.php">
<DynamicDNS VisibleName="Dynamic DNS" order="10" url="/services_dyndns.php">
<Edit url="/services_dyndns_edit.php*" visibility="hidden"/>
</DynDNS>
</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"/>
......
[reload]
command:/usr/local/etc/rc.dyndns.update
description:DynDNS Update
description:Dynamic DNS Update
parameters:%s
type:script
message:updating dyndns %s
......@@ -30,6 +30,7 @@
require_once("guiconfig.inc");
require_once("interfaces.inc");
require_once("services.inc");
require_once("system.inc");
require_once("plugins.inc.d/dyndns.inc");
if (empty($config['dyndnses']['dyndns']) || !isset($config['dyndnses']['dyndns'])) {
......@@ -44,7 +45,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
@unlink("/conf/dyndns_{$conf['interface']}{$conf['type']}" . escapeshellarg($conf['host']) . "{$conf['id']}.cache");
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 +56,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 +84,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");?>",
......
......@@ -30,6 +30,7 @@
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 */
......@@ -162,17 +163,22 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
}
write_config();
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">
......
......@@ -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();
......@@ -42,7 +44,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (!empty($a_rfc2136[$_POST['id']])) {
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 +55,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() {
......
......@@ -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,12 +111,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
}
write_config('New/Edited RFC2136 dnsupdate entry was posted');
system_cron_configure();
if (!empty($pconfig['force'])) {
rfc2136_configure_do(false, '', $rfc2136['host'], true);
} else {
rfc2136_configure_do();
}
header(url_safe('Location: /services_rfc2136.php'));
exit;
}
......@@ -246,8 +248,8 @@ include("head.inc");
<td>&nbsp;</td>
<td>
<input name="save" type="submit" class="btn btn-primary" value="<?=gettext("Save");?>" onclick="enable_change(true)" />
<input name="force" type="submit" class="btn btn-primary" value="<?=gettext("Save &amp; Force Update");?>" 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)" />
<?php if (isset($id)): ?>
<input name="id" type="hidden" value="<?=$id;?>" />
<?php endif; ?>
......
......@@ -58,6 +58,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
$dyn_dns_status_title = gettext('DynDNS');
$dyn_dns_status_title = gettext('Dynamic DNS');
$dyn_dns_status_title_link = 'services_dyndns.php';
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