diff --git a/net/chrony/Makefile b/net/chrony/Makefile index d4d807ea8b..00a06140da 100644 --- a/net/chrony/Makefile +++ b/net/chrony/Makefile @@ -1,5 +1,5 @@ PLUGIN_NAME= chrony -PLUGIN_VERSION= 1.5 +PLUGIN_VERSION= 1.6 PLUGIN_REVISION= 3 PLUGIN_COMMENT= Chrony time synchronisation PLUGIN_DEPENDS= chrony diff --git a/net/chrony/pkg-descr b/net/chrony/pkg-descr index f38222784a..7c7d2425b4 100644 --- a/net/chrony/pkg-descr +++ b/net/chrony/pkg-descr @@ -4,6 +4,18 @@ better in virtual environments. Plugin Changelog ---------------- +1.6 + +* Update config UI to expose the following features: + - local/orphan mode + - pools + - prefer + - iburst + - min/max poll + - interleaving +* Add per-source NTS option +* Add NTP data diagnostics + 1.5 * Allow adding a fallback NTP when using NTS diff --git a/net/chrony/src/opnsense/mvc/app/controllers/OPNsense/Chrony/Api/GeneralController.php b/net/chrony/src/opnsense/mvc/app/controllers/OPNsense/Chrony/Api/GeneralController.php index d96f5a1213..51fb579c01 100644 --- a/net/chrony/src/opnsense/mvc/app/controllers/OPNsense/Chrony/Api/GeneralController.php +++ b/net/chrony/src/opnsense/mvc/app/controllers/OPNsense/Chrony/Api/GeneralController.php @@ -32,6 +32,36 @@ class GeneralController extends ApiMutableModelControllerBase { - protected static $internalModelClass = '\OPNsense\Chrony\General'; protected static $internalModelName = 'general'; + protected static $internalModelClass = '\OPNsense\Chrony\General'; + + public function searchItemAction() + { + return $this->searchBase("peers.peer", null, "address"); + } + + public function setItemAction($uuid) + { + return $this->setBase("peer", "peers.peer", $uuid); + } + + public function addItemAction() + { + return $this->addBase("peer", "peers.peer"); + } + + public function getItemAction($uuid = null) + { + return $this->getBase("peer", "peers.peer", $uuid); + } + + public function delItemAction($uuid) + { + return $this->delBase("peers.peer", $uuid); + } + + public function toggleItemAction($uuid, $enabled = null) + { + return $this->toggleBase("peers.peer", $uuid, $enabled); + } } diff --git a/net/chrony/src/opnsense/mvc/app/controllers/OPNsense/Chrony/Api/ServiceController.php b/net/chrony/src/opnsense/mvc/app/controllers/OPNsense/Chrony/Api/ServiceController.php index e3a6813908..2c88330d0b 100644 --- a/net/chrony/src/opnsense/mvc/app/controllers/OPNsense/Chrony/Api/ServiceController.php +++ b/net/chrony/src/opnsense/mvc/app/controllers/OPNsense/Chrony/Api/ServiceController.php @@ -82,4 +82,15 @@ public function chronyauthdataAction() $response = $backend->configdRun("chrony chronyauthdata"); return array("response" => $response); } + + /** + * show chrony ntpdata + * @return array + */ + public function chronyntpdataAction() + { + $backend = new Backend(); + $response = $backend->configdRun("chrony chronyntpdata"); + return array("response" => $response); + } } diff --git a/net/chrony/src/opnsense/mvc/app/controllers/OPNsense/Chrony/GeneralController.php b/net/chrony/src/opnsense/mvc/app/controllers/OPNsense/Chrony/IndexController.php similarity index 85% rename from net/chrony/src/opnsense/mvc/app/controllers/OPNsense/Chrony/GeneralController.php rename to net/chrony/src/opnsense/mvc/app/controllers/OPNsense/Chrony/IndexController.php index faa214b6a0..088f439543 100644 --- a/net/chrony/src/opnsense/mvc/app/controllers/OPNsense/Chrony/GeneralController.php +++ b/net/chrony/src/opnsense/mvc/app/controllers/OPNsense/Chrony/IndexController.php @@ -28,11 +28,13 @@ namespace OPNsense\Chrony; -class GeneralController extends \OPNsense\Base\IndexController +class IndexController extends \OPNsense\Base\IndexController { public function indexAction() { + $this->view->pick('OPNsense/Chrony/index'); $this->view->generalForm = $this->getForm('general'); - $this->view->pick('OPNsense/Chrony/general'); + $this->view->formDialogPeer = $this->getForm("dialogPeer"); + $this->view->formGridPeer = $this->getFormGrid("dialogPeer"); } } diff --git a/net/chrony/src/opnsense/mvc/app/controllers/OPNsense/Chrony/forms/dialogPeer.xml b/net/chrony/src/opnsense/mvc/app/controllers/OPNsense/Chrony/forms/dialogPeer.xml new file mode 100644 index 0000000000..6e498422a5 --- /dev/null +++ b/net/chrony/src/opnsense/mvc/app/controllers/OPNsense/Chrony/forms/dialogPeer.xml @@ -0,0 +1,75 @@ +
+ + peer.pool + + checkbox + Address refers to a pool of NTP servers + + 6em + boolean + boolean + + + + peer.address + + text + The address/hostname of the NTP server or pool. + + + peer.prefer + + checkbox + Prefer this source over sources without the prefer option. + + 6em + boolean + boolean + + + + peer.iburst + + checkbox + Enable iburst for this source. + + 6em + boolean + boolean + + + + peer.xleave + + checkbox + Enable interleaved mode for this source. + + 6em + boolean + boolean + + + + peer.minpoll + + text + The minimum interval between requests sent to the server as a power of 2 in seconds. + + + peer.maxpoll + + text + The maximum interval between requests sent to the server as a power of 2 in seconds. + + + peer.nts + + checkbox + Enable NTS authentication. + + 6em + boolean + boolean + + +
\ No newline at end of file diff --git a/net/chrony/src/opnsense/mvc/app/controllers/OPNsense/Chrony/forms/general.xml b/net/chrony/src/opnsense/mvc/app/controllers/OPNsense/Chrony/forms/general.xml index 3b6b358ffb..ba5a0ccbee 100644 --- a/net/chrony/src/opnsense/mvc/app/controllers/OPNsense/Chrony/forms/general.xml +++ b/net/chrony/src/opnsense/mvc/app/controllers/OPNsense/Chrony/forms/general.xml @@ -6,36 +6,22 @@ Enable Chrony time daemon. - general.port - + general.localstratum + text - Set the port chrony listen to. - - - general.ntsclient - - checkbox - Enable NTS in client mode. This will add another layer of security for peers when OPNsense is the client. Every server in Peers has to support NTS. + (1-15) Local mode allows the system clock to be used when no other clocks are available. The number here specifies the stratum reported by the local clock and should normally be set to a number high enough to ensure that any other servers available to clients are preferred over this server. - general.ntsnocert - + general.orphanmode + checkbox - If you run NTS mode you can enable this option in order to ignore wrong time in certificates for the first check. This helps if your system starts with wrong time. + - general.peers - - - select_multiple - true - Set as many NTP peers you need. - - - general.fallbackpeers - + general.port + text - Set fallback peer if you use NTS and your system starts with wrong time. Best to only use this for internal trusted peers. + Set the port chrony listen to. general.allowednetworks @@ -45,4 +31,10 @@ true Set the networks allowed to synchronize time with this server. If this value is not set it will also not listen to the port and just synchronize the time for itself. + + general.ntsnocert + + checkbox + If you run NTS mode you can enable this option in order to ignore wrong time in certificates for the first check. This helps if your system starts with wrong time. + diff --git a/net/chrony/src/opnsense/mvc/app/models/OPNsense/Chrony/General.xml b/net/chrony/src/opnsense/mvc/app/models/OPNsense/Chrony/General.xml index 08d29de0cf..78f763a850 100644 --- a/net/chrony/src/opnsense/mvc/app/models/OPNsense/Chrony/General.xml +++ b/net/chrony/src/opnsense/mvc/app/models/OPNsense/Chrony/General.xml @@ -7,31 +7,68 @@ 0 Y - - 323 - Y - - - 0 - Y - - + + 1 + 15 + N + Local stratum must be within 1-15. + + 0 Y - - - 0.opnsense.pool.ntp.org + + + 123 Y - , - Y - - - N - + N , Y + + 0 + Y + + + + + 0 + Y + +
+ opnsense.pool.ntp.org + Y +
+ + 0 + Y + + + 0 + Y + + + 0 + Y + + + -6 + 24 + N + minpoll value must be between -6 and 24. + + + -6 + 24 + N + maxpoll value must be between -6 and 24. + + + 0 + Y + +
+
diff --git a/net/chrony/src/opnsense/mvc/app/models/OPNsense/Chrony/Menu/Menu.xml b/net/chrony/src/opnsense/mvc/app/models/OPNsense/Chrony/Menu/Menu.xml index e11f5fe9cb..fef1b45bd5 100644 --- a/net/chrony/src/opnsense/mvc/app/models/OPNsense/Chrony/Menu/Menu.xml +++ b/net/chrony/src/opnsense/mvc/app/models/OPNsense/Chrony/Menu/Menu.xml @@ -1,7 +1,7 @@ - + diff --git a/net/chrony/src/opnsense/mvc/app/views/OPNsense/Chrony/general.volt b/net/chrony/src/opnsense/mvc/app/views/OPNsense/Chrony/index.volt similarity index 56% rename from net/chrony/src/opnsense/mvc/app/views/OPNsense/Chrony/general.volt rename to net/chrony/src/opnsense/mvc/app/views/OPNsense/Chrony/index.volt index 40d7552e95..998b54351c 100644 --- a/net/chrony/src/opnsense/mvc/app/views/OPNsense/Chrony/general.volt +++ b/net/chrony/src/opnsense/mvc/app/views/OPNsense/Chrony/index.volt @@ -31,12 +31,20 @@
  • {{ lang._('Source Stats') }}
  • {{ lang._('Tracking') }}
  • {{ lang._('Auth Data') }}
  • +
  • {{ lang._('NTP Data') }}
  • {{ partial("layout_partials/base_form",['fields':generalForm,'id':'frm_general_settings'])}} + +

    {{ lang._('Sources') }}

    + + {{ partial('layout_partials/base_bootgrid_table', formGridPeer) }} + + {{ partial("layout_partials/base_dialog",['fields':formDialogPeer,'id':formGridPeer['edit_dialog_id'],'label':lang._('Edit source')])}} +

    @@ -55,10 +63,38 @@
    
         
    +
    +
    
    +    
    diff --git a/net/chrony/src/opnsense/service/conf/actions.d/actions_chrony.conf b/net/chrony/src/opnsense/service/conf/actions.d/actions_chrony.conf index a8fd65f27d..74c4253f9d 100644 --- a/net/chrony/src/opnsense/service/conf/actions.d/actions_chrony.conf +++ b/net/chrony/src/opnsense/service/conf/actions.d/actions_chrony.conf @@ -23,13 +23,13 @@ type:script_output message:request chrony status [chronysources] -command:/usr/local/bin/chronyc -m 'timeout 100' 'retries 0' sources +command:/usr/local/bin/chronyc -m 'timeout 100' 'retries 0' 'sources -v' parameters: type:script_output message:show chrony sources [chronysourcestats] -command:/usr/local/bin/chronyc -m 'timeout 100' 'retries 0' sourcestats +command:/usr/local/bin/chronyc -m 'timeout 100' 'retries 0' 'sourcestats -v' parameters: type:script_output message:show chrony sourcestats @@ -41,7 +41,13 @@ type:script_output message:show chrony tracking [chronyauthdata] -command:/usr/local/bin/chronyc -N -m 'timeout 100' 'retries 0' authdata +command:/usr/local/bin/chronyc -N -m 'timeout 100' 'retries 0' 'authdata -v' parameters: type:script_output message:show chrony authdata + +[chronyntpdata] +command:/usr/local/bin/chronyc -N -m 'timeout 100' 'retries 0' ntpdata +parameters: +type:script_output +message:show chrony ntpdata \ No newline at end of file diff --git a/net/chrony/src/opnsense/service/templates/OPNsense/Chrony/chrony.conf b/net/chrony/src/opnsense/service/templates/OPNsense/Chrony/chrony.conf index 7cd4f7a16f..364f6ea59f 100644 --- a/net/chrony/src/opnsense/service/templates/OPNsense/Chrony/chrony.conf +++ b/net/chrony/src/opnsense/service/templates/OPNsense/Chrony/chrony.conf @@ -1,36 +1,35 @@ {% if helpers.exists('OPNsense.chrony.general.enabled') and OPNsense.chrony.general.enabled == '1' %} port {{ OPNsense.chrony.general.port }} +{% if not helpers.empty('OPNsense.chrony.general.allowednetworks') %} +{% for network in OPNsense.chrony.general.allowednetworks.split(',') %} +allow {{ network }} +{% endfor %} +{% endif %} + +{% if not helpers.empty('OPNsense.chrony.general.peers') %} +{% set peers = OPNsense.chrony.general.peers.peer %} +{% if peers is mapping %} +{% set peers = [peers] %} +{% endif %} +{% for peer in peers %} +{% if peer.pool == '1' %}pool {% else %}server {% endif %}{{peer.address}}{% if peer.prefer == '1' %} prefer{% endif %}{% if peer.iburst == '1' %} iburst{% endif %}{% if peer.xleave == '1' %} xleave{% endif %}{% if peer.minpoll is defined and peer.minpoll != '' %} minpoll {{ peer.minpoll }}{% endif %}{% if peer.maxpoll is defined and peer.maxpoll != '' %} maxpoll {{ peer.maxpoll }}{% endif %}{% if peer.nts == '1' %} nts{% endif %} + +{% endfor %} +{% endif %} + +{% if not helpers.empty('OPNsense.chrony.general.localstratum') %} +local stratum {{ OPNsense.chrony.general.localstratum }} {% if helpers.exists('OPNsense.chrony.general.orphanmode') and OPNsense.chrony.general.orphanmode == '1' %}orphan{% endif %} + +{% endif %} driftfile /var/db/chrony/drift pidfile /var/run/chrony/chronyd.pid makestep 1 3 -{% if helpers.exists('OPNsense.chrony.general.ntsclient') and OPNsense.chrony.general.ntsclient == '1' %} ntsdumpdir /var/lib/chrony -ntstrustedcerts /usr/local/etc/ssl/cert.pem -nosystemcert -{% endif %} -{% if helpers.exists('OPNsense.chrony.general.ntsnocert') and OPNsense.chrony.general.ntsnocert == '1' %} +{% if helpers.exists('OPNsense.chrony.general.ntsnocert') and OPNsense.chrony.general.ntsnocert == '1' %} nocerttimecheck 1 -{% endif %} - -{% if not helpers.empty('OPNsense.chrony.general.peers') %} -{% for peer in OPNsense.chrony.general.peers.split(',') %} -server {{ peer }} iburst {% if helpers.exists('OPNsense.chrony.general.ntsclient') and OPNsense.chrony.general.ntsclient == '1' %}nts{% endif %} - -{% endfor %} -{% endif %} - -{% if helpers.exists('OPNsense.chrony.general.fallbackpeers') and OPNsense.chrony.general.fallbackpeers != '' %} -authselectmode mix -server {{ OPNsense.chrony.general.fallbackpeers }} -{% endif %} - -{% if not helpers.empty('OPNsense.chrony.general.allowednetworks') %} -{% for network in OPNsense.chrony.general.allowednetworks.split(',') %} -allow {{ network }} -{% endfor %} -{% endif %} +{% endif %} {% endif %}