<commit_before>--[[
LuCI model for mosquitto MQTT broker configuration management
Copyright eT<NAME>, 2018

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

]]--

local datatypes = require("luci.cbi.datatypes")
local _ = luci.i18n.translate

--- Like a Flag, but with an option to remove/set to default.
local function OptionalFlag(section, key, title, description)
    local o = section:option(ListValue, key, title, description)
    o.optional = true
    o:value("", "Default")
    o:value("1", "Enabled")
    o:value("0", "Disabled")
    return o
end

m = Map("mosquitto", _("Mosquitto MQTT Broker"),
    _([[mosquitto - the <a href='http://www.mosquitto.org'>blood thirsty</a>
MQTT messaging broker.  Note, only some of the available configuration files
 are supported at this stage, use the checkbox below to use config generated
 by this page, or the stock mosquitto configuration file in 
 /etc/mosquitto/mosquitto.conf]]))
 
s = m:section(TypedSection, "owrt", "OpenWRT")
s.anonymous = true
p = s:option(Flag, "use_uci", _("Use this LuCI configuration page"),
	_([[If checked, mosquitto runs with a config generated
	from this page. (Or from UCI directly)  If unchecked, mosquitto
        runs with the config in /etc/mosquitto/mosquitto.conf
        (and this page is ignored)]]))

s = m:section(TypedSection, "mosquitto", "Mosquitto")
s.anonymous = true

p = s:option(MultiValue, "log_dest", _("Log destination"),
    _("You can have multiple, but 'none' will override all others"))
p:value("stderr", "stderr")
p:value("stdout", "stdout")
p:value("syslog", "syslog")
p:value("topic", "$SYS/broker/log/[severity]")
p:value("none", "none")

OptionalFlag(s, "no_remote_access", _("Disallow remote access to this broker"),
    _([[Outbound bridges will still work, but this will make the primary listener
    only available from localhost]]))

local o
o = s:option(Value, "sys_interval", _("Time in seconds between updates of the $SYS tree"), _("Set to zero to disable"))
o.datatype = "uinteger"
o.optional = true

o = s:option(Value, "max_inflight_messages", _("Max Inflight Messages"), _("Limit for message allowed inflight"))
o.datatype = "uinteger"
o.optional = true
o = s:option(Value, "max_queued_messages", _("Max Queued Messages"), _("Limit for message queue when offline"))
o.datatype = "uinteger"<commit_msg>luci-app-mosquitto: add option 'allow anonymous'<commit_after>--[[
LuCI model for mosquitto MQTT broker configuration management
Copyright eTactica ehf, 2018

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

]]--

local datatypes = require("luci.cbi.datatypes")
local _ = luci.i18n.translate

--- Like a Flag, but with an option to remove/set to default.
local function OptionalFlag(section, key, title, description)
    local o = section:option(ListValue, key, title, description)
    o.optional = true
    o:value("", "Default")
    o:value("1", "Enabled")
    o:value("0", "Disabled")
    return o
end

m = Map("mosquitto", _("Mosquitto MQTT Broker"),
    _([[mosquitto - the <a href='http://www.mosquitto.org'>blood thirsty</a>
MQTT messaging broker.  Note, only some of the available configuration files
 are supported at this stage, use the checkbox below to use config generated
 by this page, or the stock mosquitto configuration file in 
 /etc/mosquitto/mosquitto.conf]]))
 
s = m:section(TypedSection, "owrt", "OpenWRT")
s.anonymous = true
p = s:option(Flag, "use_uci", _("Use this LuCI configuration page"),
	_([[If checked, mosquitto runs with a config generated
	from this page. (Or from UCI directly)  If unchecked, mosquitto
        runs with the config in /etc/mosquitto/mosquitto.conf
        (and this page is ignored)]]))

s = m:section(TypedSection, "mosquitto", "Mosquitto")
s.anonymous = true

p = s:option(MultiValue, "log_dest", _("Log destination"),
    _("You can have multiple, but 'none' will override all others"))
p:value("stderr", "stderr")
p:value("stdout", "stdout")
p:value("syslog", "syslog")
p:value("topic", "$SYS/broker/log/[severity]")
p:value("none", "none")

OptionalFlag(s, "no_remote_access", _("Disallow remote access to this broker"),
    _([[Outbound bridges will still work, but this will make the primary listener
    only available from localhost]]))

local o
o = s:option(Value, "sys_interval", _("Time in seconds between updates of the $SYS tree"), _("Set to zero to disable"))
o.datatype = "uinteger"
o.optional = true

OptionalFlag(s, "allow_anonymous", _("Allow anonymous connections"), _("Allow to connect without providing a username and password"))
o = s:option(Value, "max_inflight_messages", _("Max Inflight Messages"), _("Limit for message allowed inflight"))
o.datatype = "uinteger"
o.optional = true
o = s:option(Value, "max_queued_messages", _("Max Queued Messages"), _("Limit for message queue when offline"))
o.datatype = "uinteger"
{'fraction_non_alphanumeric': 0.1312173408167215, 'fraction_numerical': 0.00464486162183085, 'mean_word_length': 4.806741573033708, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5324225', 'n_tokens_mistral': 1678, 'n_tokens_neox': 1616, 'n_words': 572}