mirror of
https://github.com/netbirdio/plugins.git
synced 2026-05-22 18:44:07 -07:00
dns/ddclient - work in progress, replacement for dyndns using ddclient package
This commit is contained in:
+49
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2021 Deciso B.V.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OPNsense\DynDNS\Api;
|
||||
|
||||
use OPNsense\Base\ApiMutableModelControllerBase;
|
||||
|
||||
class SettingsController extends ApiMutableModelControllerBase
|
||||
{
|
||||
protected static $internalModelName = 'ddclient';
|
||||
protected static $internalModelClass = 'OPNsense\DynDNS\DynDNS';
|
||||
|
||||
public function getAction()
|
||||
{
|
||||
$data = parent::getAction();
|
||||
return [
|
||||
'ddclient' => [
|
||||
'general' => $data['ddclient']['general']
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,7 @@ class IndexController extends \OPNsense\Base\IndexController
|
||||
{
|
||||
// link dialogs
|
||||
$this->view->formDialogAccount = $this->getForm("dialogAccount");
|
||||
$this->view->formSettings = $this->getForm("settings");
|
||||
// choose template
|
||||
$this->view->pick('OPNsense/DynDNS/index');
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<form>
|
||||
<field>
|
||||
<id>ddclient.general.enabled</id>
|
||||
<label>Enable</label>
|
||||
<type>checkbox</type>
|
||||
<help>Enable ddclient</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>ddclient.general.checkip</id>
|
||||
<label>Check ip method</label>
|
||||
<type>dropdown</type>
|
||||
<help>
|
||||
How to determine the address to uswe for this host
|
||||
</help>
|
||||
</field>
|
||||
</form>
|
||||
@@ -10,6 +10,28 @@
|
||||
<default>1</default>
|
||||
<Required>Y</Required>
|
||||
</enabled>
|
||||
<checkip type="OptionField">
|
||||
<Required>Y</Required>
|
||||
<default>web_dyndns</default>
|
||||
<ValidationMessage>An IP service type is required.</ValidationMessage>
|
||||
<OptionValues>
|
||||
<web_dyndns>dyndns</web_dyndns>
|
||||
<web_freedns>freedns</web_freedns>
|
||||
<web_googledomains>googledomains</web_googledomains>
|
||||
<web_he>he</web_he>
|
||||
<web_ip4only_me value="web_ip4only.me">ip4only.me</web_ip4only_me>
|
||||
<web_ip6only_me value="web_ip6only.me">ip4only.me</web_ip6only_me>
|
||||
<web_ipify_ipv4 value="web_ipify-ipv4">ipify-ipv4</web_ipify_ipv4>
|
||||
<web_ipify_ipv6 value="web_ipify-ipv6">ipify-ipv6</web_ipify_ipv6>
|
||||
<web_loopia>loopia</web_loopia>
|
||||
<web_myonlineportal>myonlineportal</web_myonlineportal>
|
||||
<web_noip_ipv4 value="web_noip-ipv4">noip-ipv4</web_noip_ipv4>
|
||||
<web_noip_ipv6 value="web_noip-ipv6">noip-ipv6</web_noip_ipv6>
|
||||
<web_nsupdate_info_ipv4 value="web_nsupdate.info-ipv4">nsupdate.info-ipv4</web_nsupdate_info_ipv4>
|
||||
<web_nsupdate_info_ipv6 value="web_nsupdate.info-ipv6">nsupdate.info-ipv4</web_nsupdate_info_ipv6>
|
||||
<web_zoneedit>zoneedit</web_zoneedit>
|
||||
</OptionValues>
|
||||
</checkip>
|
||||
</general>
|
||||
<accounts>
|
||||
<account type="ArrayField">
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<menu>
|
||||
<Services>
|
||||
<DynamicDNS VisibleName="Dynamic DNS" url="/ui/dyndns/" cssClass="fa fa-tags fa-fw"/>
|
||||
<DynamicDNS VisibleName="Dynamic DNS" cssClass="fa fa-tags fa-fw">
|
||||
<settings order="10" url="/ui/dyndns/"/>
|
||||
<log order="100" VisibleName="Log File" url="/ui/diagnostics/log/core/ddclient"/>
|
||||
</DynamicDNS>
|
||||
</Services>
|
||||
</menu>
|
||||
|
||||
@@ -38,15 +38,29 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
toggle:'/api/dyndns/accounts/toggle_item/'
|
||||
}
|
||||
);
|
||||
let data_get_map = {'frm_settings':"/api/dyndns/settings/get"};
|
||||
mapDataToFormUI(data_get_map).done(function(){
|
||||
formatTokenizersUI();
|
||||
$('.selectpicker').selectpicker('refresh');
|
||||
updateServiceControlUI('dyndns');
|
||||
});
|
||||
|
||||
$("#reconfigureAct").SimpleActionButton();
|
||||
updateServiceControlUI('dyndns');
|
||||
$("#reconfigureAct").SimpleActionButton({
|
||||
onPreAction: function() {
|
||||
const dfObj = new $.Deferred();
|
||||
saveFormToEndpoint("/api/dyndns/settings/set", 'frm_settings', function(){
|
||||
dfObj.resolve();
|
||||
});
|
||||
return dfObj;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<ul class="nav nav-tabs" data-tabs="tabs" id="maintabs">
|
||||
<li class="active"><a data-toggle="tab" id="destinations" href="#tab_destinations">{{ lang._('Accounts') }}</a></li>
|
||||
<li class="active"><a data-toggle="tab" id="destinations" href="#tab_accounts">{{ lang._('Accounts') }}</a></li>
|
||||
<li><a data-toggle="tab" href="#settings" id="settings_tab">{{ lang._('General settings') }}</a></li>
|
||||
</ul>
|
||||
<div class="tab-content content-box">
|
||||
<div id="tab_accounts" class="tab-pane fade in active">
|
||||
@@ -75,22 +89,29 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<div id="ddclientChangeMessage" class="alert alert-info" style="display: none" role="alert">
|
||||
{{ lang._('After changing settings, please remember to apply them with the button below') }}
|
||||
</div>
|
||||
<hr/>
|
||||
<button class="btn btn-primary" id="reconfigureAct"
|
||||
data-endpoint='/api/dyndns/service/reconfigure'
|
||||
data-label="{{ lang._('Apply') }}"
|
||||
data-service-widget="dyndns"
|
||||
data-error-title="{{ lang._('Error reconfiguring DynDNS') }}"
|
||||
type="button"
|
||||
></button>
|
||||
<br/><br/>
|
||||
<div id="settings" class="tab-pane fade in">
|
||||
{{ partial("layout_partials/base_form",['fields':formSettings,'id':'frm_settings'])}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="page-content-main">
|
||||
<div class="content-box">
|
||||
<div class="col-md-12">
|
||||
<br/>
|
||||
<div id="ddclientChangeMessage" class="alert alert-info" style="display: none" role="alert">
|
||||
{{ lang._('After changing settings, please remember to apply them with the button below') }}
|
||||
</div>
|
||||
<button class="btn btn-primary" id="reconfigureAct"
|
||||
data-endpoint='/api/dyndns/service/reconfigure'
|
||||
data-label="{{ lang._('Apply') }}"
|
||||
data-service-widget="dyndns"
|
||||
data-error-title="{{ lang._('Error reconfiguring DynDNS') }}"
|
||||
type="button"
|
||||
></button>
|
||||
<br/><br/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{# include dialogs #}
|
||||
{{ partial("layout_partials/base_dialog",['fields':formDialogAccount,'id':'DialogAccount','label':lang._('Edit Account')])}}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
###################################################################
|
||||
# Local syslog-ng configuration filter definition [ddclient].
|
||||
###################################################################
|
||||
filter f_local_ddclient {
|
||||
program("ddclient");
|
||||
};
|
||||
@@ -2,44 +2,63 @@ daemon=300 # check every 300 seconds
|
||||
syslog=yes # log update msgs to syslog
|
||||
pid=/var/run/ddclient.pid # record PID in file.
|
||||
|
||||
{% set websettings = {
|
||||
'noip': 'use=web,',
|
||||
'nsupdate': 'use=web, web=http://ipv4.nsupdate.info/myip,'
|
||||
} %}
|
||||
|
||||
#
|
||||
# setup how we expect to retrieve an IP address
|
||||
#
|
||||
{% if not helpers.empty('OPNsense.DynDNS.general.checkip') and OPNsense.DynDNS.general.checkip.startswith('web_') %}
|
||||
{% set checkip = OPNsense.DynDNS.general.checkip.lstrip('web_') %}
|
||||
{% if checkip == 'dyndns' %}
|
||||
use=web, web=http://checkip.dyndns.org/, web-skip="Current IP Address:"
|
||||
{% elif checkip == 'freedns' %}
|
||||
use=web, web=https://freedns.afraid.org/dynamic/check.php
|
||||
{% elif checkip == 'googledomains' %}
|
||||
use=web, web=https://domains.google.com/checkip
|
||||
{% elif checkip == 'he' %}
|
||||
use=web, web=http://checkip.dns.he.net/
|
||||
{% elif checkip == 'ip4only.me' %}
|
||||
use=web, web=http://ip4only.me/api/
|
||||
{% elif checkip == 'ip6only.me' %}
|
||||
use=web, web=http://ip6only.me/api/
|
||||
{% elif checkip == 'ipify-ipv4' %}
|
||||
use=web, web=https://api.ipify.org/
|
||||
{% elif checkip == 'ipify-ipv6' %}
|
||||
use=web, web=https://api6.ipify.org/
|
||||
{% elif checkip == 'loopia' %}
|
||||
use=web, web=http://dns.loopia.se/checkip/checkip.php, web-skip="Current IP Address:"
|
||||
{% elif checkip == 'myonlineportal' %}
|
||||
use=web, web=https://myonlineportal.net/checkip
|
||||
{% elif checkip == 'noip-ipv4' %}
|
||||
use=web, web=http://ip1.dynupdate.no-ip.com/
|
||||
{% elif checkip == 'noip-ipv6' %}
|
||||
use=web, web=http://ip1.dynupdate6.no-ip.com/
|
||||
{% elif checkip == 'nsupdate.info-ipv4' %}
|
||||
use=web, web=https://ipv4.nsupdate.info/myip
|
||||
{% elif checkip == 'nsupdate.info-ipv6' %}
|
||||
use=web, web=https://ipv6.nsupdate.info/myip
|
||||
{% elif checkip == 'zoneedit' %}
|
||||
use=web, web=http://dynamic.zoneedit.com/checkip.html
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if helpers.exists('OPNsense.DynDNS.accounts.account') %}
|
||||
{% for account in helpers.toList('OPNsense.DynDNS.accounts.account') %}
|
||||
{% if account.enabled|default('0') == '1' %}
|
||||
{% if account.service == 'noip' %}
|
||||
|
||||
protocol=noip, \
|
||||
use=web, \
|
||||
ssl=yes, \
|
||||
login={{account.username}}, \
|
||||
password={{account.password}} \
|
||||
{{account.hostnames}}
|
||||
|
||||
protocol=noip
|
||||
ssl=yes
|
||||
{% elif account.service == 'nsupdatev4' %}
|
||||
|
||||
protocol=dyndns2, \
|
||||
use=web, web=https://ipv4.nsupdate.info/myip, \
|
||||
ssl=yes, \
|
||||
server=ipv4.nsupdate.info, \
|
||||
login={{account.username}}, \
|
||||
password='{{account.password}}' \
|
||||
{{account.hostnames}}
|
||||
|
||||
protocol=dyndns2
|
||||
ssl=yes
|
||||
server=ipv4.nsupdate.info
|
||||
{% elif account.service == 'nsupdatev6' %}
|
||||
protocol=dyndns2, \
|
||||
use=web, web=https://ipv6.nsupdate.info/myip, \
|
||||
ssl=yes, \
|
||||
server=ipv6.nsupdate.info, \
|
||||
login={{account.username}}, \
|
||||
password='{{account.password}}' \
|
||||
protocol=dyndns2
|
||||
ssl=yes
|
||||
server=ipv6.nsupdate.info
|
||||
{% endif %}
|
||||
login={{account.username}}
|
||||
password={{account.password}}
|
||||
{{account.hostnames}}
|
||||
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user