mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-15 09:04:39 +00:00
dyndns: move to plugins.inc.d #1478
Also try to unclog the use of requires and naming, we don't want stuff like "dyndns/dyndns.class" so let's go back to the roots and call the file phpdns.inc like the original prjoject was.
This commit is contained in:
parent
c89569dbc3
commit
e8b9968029
5
plist
5
plist
@ -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
|
||||
@ -36,6 +34,9 @@
|
||||
/usr/local/etc/inc/notices.smtp.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/phpdns.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
|
||||
/usr/local/etc/inc/plugins.inc.d/ipsec/auth-user.php
|
||||
|
||||
140
src/etc/inc/plugins.inc.d/dyndns.inc
Normal file
140
src/etc/inc/plugins.inc.d/dyndns.inc
Normal file
@ -0,0 +1,140 @@
|
||||
<?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/phpdns.inc');
|
||||
require_once('plugins.inc.d/dyndns/r53.inc');
|
||||
|
||||
function dyndns_configure()
|
||||
{
|
||||
return array(
|
||||
'local' => array('dyndns_configure_do'),
|
||||
'interface' => array('dyndns_configure_do:2'),
|
||||
);
|
||||
}
|
||||
|
||||
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_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 (!isset($config['dyndnses']['dyndns'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$dyndnscfg = $config['dyndnses']['dyndns'];
|
||||
$gwgroups = return_gateway_groups_array();
|
||||
if (!is_array($dyndnscfg)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($verbose) {
|
||||
echo 'Starting 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";
|
||||
}
|
||||
}
|
||||
@ -544,10 +544,6 @@
|
||||
$NewIP=$this->_dnsIP;
|
||||
$NewTTL=$this->_dnsTTL;
|
||||
|
||||
/* Include Route 53 Library Class (and util.inc for log_error) */
|
||||
require_once('util.inc');
|
||||
require_once('dyndns.r53.class');
|
||||
|
||||
/* Set Amazon AWS Credentials for this record */
|
||||
$r53 = new Route53($AccessKeyId, $SecretAccessKey);
|
||||
|
||||
@ -44,7 +44,7 @@
|
||||
* targets in the future:
|
||||
*/
|
||||
require_once('plugins.inc.d/dnsmasq.inc');
|
||||
require_once('dyndns.class'); /* XXX move to plugin */
|
||||
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');
|
||||
@ -1550,103 +1550,6 @@ function services_dhcrelay6_configure($verbose = false)
|
||||
}
|
||||
}
|
||||
|
||||
function services_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 services_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 services_dyndns_configure($int = '', $verbose = false)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (isset($config['dyndnses']['dyndns'])) {
|
||||
$dyndnscfg = $config['dyndnses']['dyndns'];
|
||||
$gwgroups = return_gateway_groups_array();
|
||||
if (is_array($dyndnscfg)) {
|
||||
if ($verbose) {
|
||||
echo 'Starting 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']);
|
||||
services_dyndns_configure_client($dyndns);
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
if ($verbose) {
|
||||
echo "done.\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
function dyndnsCheckIP($int)
|
||||
{
|
||||
global $config;
|
||||
|
||||
@ -42,13 +42,13 @@ if (isset($argv[1])) {
|
||||
}
|
||||
|
||||
if (empty($argument)) {
|
||||
services_dyndns_configure();
|
||||
rfc2136_configure_do(false);
|
||||
dyndns_configure_do();
|
||||
rfc2136_configure_do();
|
||||
} else {
|
||||
$interface = lookup_gateway_interface_by_name($argument);
|
||||
if (empty($interface)) {
|
||||
$interface = $argument;
|
||||
}
|
||||
services_dyndns_configure($interface);
|
||||
dyndns_configure_do(false, $interface);
|
||||
rfc2136_configure_do(false, $interface);
|
||||
}
|
||||
|
||||
@ -181,9 +181,6 @@ if (!is_ipaddr($oldip) || $curwanip != $oldip || !is_ipaddrv4($config['interface
|
||||
@file_put_contents("/var/db/{$interface}_cacheip", $curwanip);
|
||||
}
|
||||
|
||||
/* signal dyndns update */
|
||||
services_dyndns_configure($interface);
|
||||
|
||||
/* start OpenVPN server & clients */
|
||||
if (substr($interface_real, 0, 4) != "ovpn") {
|
||||
openvpn_resync_all($interface);
|
||||
|
||||
@ -137,9 +137,6 @@ if (is_ipaddrv6($oldipv6)) {
|
||||
file_put_contents("/var/db/{$interface}_cacheipv6", $curwanipv6);
|
||||
}
|
||||
|
||||
/* signal dyndns update */
|
||||
services_dyndns_configure($interface);
|
||||
|
||||
/* start OpenVPN server & clients */
|
||||
if (substr($interface_real, 0, 4) != 'ovpn') {
|
||||
openvpn_resync_all($interface);
|
||||
|
||||
@ -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);
|
||||
|
||||
mwexec_bg('/usr/local/etc/rc.sshd');
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
require_once("guiconfig.inc");
|
||||
require_once("interfaces.inc");
|
||||
require_once("services.inc");
|
||||
require_once("interfaces.inc");
|
||||
require_once("plugins.inc.d/dyndns.inc");
|
||||
|
||||
if (empty($config['dyndnses']['dyndns']) || !isset($config['dyndnses']['dyndns'])) {
|
||||
$config['dyndnses']['dyndns'] = array();
|
||||
@ -136,7 +136,7 @@ $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
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
require_once("guiconfig.inc");
|
||||
require_once("services.inc") ;
|
||||
require_once("interfaces.inc");
|
||||
require_once("plugins.inc.d/dyndns.inc");
|
||||
|
||||
/* returns true if $uname is a valid dynamic DNS username */
|
||||
function is_dyndns_username($uname)
|
||||
@ -161,7 +162,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
}
|
||||
|
||||
write_config();
|
||||
services_dyndns_configure_client($dyndns);
|
||||
dyndns_configure_client($dyndns);
|
||||
header(url_safe('Location: /services_dyndns.php'));
|
||||
exit;
|
||||
}
|
||||
@ -223,7 +224,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>
|
||||
|
||||
@ -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();
|
||||
@ -100,7 +101,7 @@ 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;?>'">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user