luci-app-statistics: Adds ability to configure encrypted connections in the MQTT package

Updates mqtt.js to add user interface to configure a path to a CA Cert file to be used by MQTT to verify the servers certificate, and adds a setting to configure the TLS verison to be used for the conneciton. Also updates stat-genconfig to then copy these settings into the generated collectd.conf

Signed-off-by: Nat Gist <nat.gist@gmail.com>
This commit is contained in:
Nat Gist
2025-08-22 20:44:02 +00:00
committed by Hannu Nyman
parent 9c7e472edb
commit 3a45003bfb
2 changed files with 15 additions and 0 deletions

View File

@@ -68,6 +68,19 @@ return baseclass.extend({
o.value('false', _('False'));
o.modalonly = true;
o.optional = true;
o = ss.option(form.ListValue, 'TLSProtocol', _('TLSProtocol'));
o.depends('blocktype', 'Publish');
o.value('tlsv1.2', _('TLS 1.2'));
o.value('tlsv1.3', _('TLS 1.3'));
o.modalonly = true;
o.optional = true;
o = ss.option(form.Value, 'CACert', _('CACert'));
o.depends({'TLSProtocol': 'tls', '!contains': true });
o.optional = true;
o.modalonly = true;
o.default = '/etc/ssl/certs/ca-certificates.crt';
o = ss.option(form.ListValue, 'CleanSession', _('CleanSession'));
o.depends('blocktype', 'Subscribe');

View File

@@ -260,6 +260,8 @@ function config_mqtt(c) {
str += s['StoreRates'] ? `\t\tRetain ${s.StoreRates}\n` : '';
str += s['CleanSession'] ? `\t\tRetain ${s.CleanSession}\n` : '';
str += s['Topic'] ? `\t\tTopic "${s.Topic}"\n` : '';
str += s['CACert'] ? `\t\tCACert "${s.CACert}"\n` : '';
str += s['TLSProtocol'] ? `\t\tTLSProtocol "${s.TLSProtocol}"\n` : '';
str += isPublish ? `\t</Publish>\n` : `\t</Subscribe>\n`;
}