Developing lightweight computation at the DSG edge

Commit 67ac9c27 authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

Merge branch 'qmpdoc' of ssh://dev.qmp.cat/qmp into qmpdoc

parents df5f0861 51e43dd4
......@@ -38,13 +38,15 @@ function index()
entry({"qmp","status"}, template("admin_status/index"), "Status", 2).dependent=false
entry({"qmp","configuration"}, cbi("qmp/easy_setup"), "Device configuration", 4).dependent=false
entry({"qmp","configuration","easy_setup"}, cbi("qmp/easy_setup"), "qMp easy setup", 1).dependent=false
entry({"qmp","configuration","basic"}, cbi("qmp/basic"), "Basic settings", 2).dependent=false
entry({"qmp","configuration","network"}, cbi("qmp/network"), "Network settings", 3).dependent=false
entry({"qmp","configuration","network","advanced"}, cbi("qmp/network_adv"), "Advanced network settings", 1).dependent=false
entry({"qmp","configuration","wifi"}, cbi("qmp/wireless"), "Wireless settings", 4).dependent=false
entry({"qmp","configuration","services"}, cbi("qmp/services"), "qMp services", 5).dependent=false
entry({"qmp","configuration","gateways"}, cbi("qmp/gateways"), "qMp gateways", 6).dependent=false
entry({"qmp","configuration","easy_setup"}, cbi("qmp/easy_setup"), "qMp easy setup", 10).dependent=false
entry({"qmp","configuration","basic"}, cbi("qmp/basic"), "Basic settings", 20).dependent=false
entry({"qmp","configuration","network"}, cbi("qmp/network_basic"), "Network settings", 30).dependent=false
entry({"qmp","configuration","network","basic"}, cbi("qmp/network_basic"), "Basic settings", 31).dependent=false
entry({"qmp","configuration","network","wired"}, cbi("qmp/network_wired"), "Wired interfaces", 32).dependent=false
entry({"qmp","configuration","network","wireless"}, cbi("qmp/network_wireless"), "Wireless interfaces", 33).dependent=false
entry({"qmp","configuration","network","advanced"}, cbi("qmp/network_adv"), "Advanced settings", 34).dependent=false
entry({"qmp","configuration","services"}, cbi("qmp/services"), "qMp services", 40).dependent=false
entry({"qmp","configuration","gateways"}, cbi("qmp/gateways"), "qMp gateways", 50).dependent=false
entry({"qmp","tools"}, call("action_tools"), "Tools", 5).dependent=false
entry({"qmp","tools","tools"}, call("action_tools"), "Network testing", 1).dependent=false
......@@ -63,7 +65,7 @@ function action_status()
local ipv4 = qmp.get_ipv4()
local hostname = qmp.get_hostname()
local uname = qmp.get_uname()
local version = qmp.get_version()
local version = qmp.get_version()
luci.template.render("qmp/overview",{ipv4=ipv4,hostname=hostname,uname=uname,version=version})
end
......@@ -83,4 +85,3 @@ end
function action_map()
luci.template.render("qmp/b6m")
end
......@@ -26,15 +26,20 @@ local uciout = uci.cursor()
package.path = package.path .. ";/etc/qmp/?.lua"
qmpinfo = require "qmpinfo"
-- Page header
m = SimpleForm("qmp", translate("qMp easy setup"), translate("This page provides a fast and simple way to configure the basic settings of a qMp device.") .. " " .. translate("Use the form below to specify the required settings, such as the node mode, name or identifier, IP address and interface operation modes.") .. "<br/> <br/>" .. translate("You can refer to the on-line documentation at <a href=\"https://www.qmp.cat/Web_interface\">https://www.qmp.cat/Web_interface</a> for more information about the different options."))
------------
-- Header --
------------
m = SimpleForm("qmp", translate("qMp easy setup"), translate("This page provides a fast and simple way to configure the basic settings of a qMp device.") .. " " .. translate("Use the form below to specify the required settings, such as the node mode, name or identifier, IP address and interface operation modes.") .. "<br/> <br/>" .. translate("You can check the on-line documentation at <a href=\"https://www.qmp.cat/Web_interface\">https://www.qmp.cat/Web_interface</a> for more information about the different options."))
---------------------------
-- Device identification --
---------------------------
-- Device name
local devicename_help
local devicename_help = m:field(DummyValue,"_devicename_help")
devicename_help.rawhtml = true
devicename_help.default = "<strong>"..translate("Device name and identification").."</strong>".."<br/> <br/>"..translate("Choose a name for this device. It will be used to identify it in the mesh network.").."<br/> <br/>"
devicename_help.default = "<h3>"..translate("Device identification").."</h3>".."<br/> <br/>"..translate("Choose a name for this device. It will be used to identify it in the mesh network.").."<br/> <br/>"
local devicename = m:field(Value, "_devicename", " ", translate("Use only alphanumeric characters, dots, dashes and underscores."))
devicename.datatype="hostname"
......@@ -93,17 +98,22 @@ if uciout:get("qmp","node","device_id") ~= nil then
end
----------------------------------------
-- Node mode and public IPv4 address --
----------------------------------------
-- Node mode
local mode_help
mode_help = m:field(DummyValue,"mode_help")
mode_help.rawhtml = true
mode_help.default = "<strong>" .. translate("Node mode") .. "</strong>" .. "<br/> <br/>" ..
mode_help.default = "<h3>" .. translate("Node mode and mesh-wide public IPv4 address") .. "</h3>" .. "<br/> <br/>" ..
translate("The <em>node mode</em> option defines whether qMp makes the devices connected to the LAN interfaces of the node visible to the rest of the mesh network or hidden behind a NAT.") .. " " ..
translate("Static, long-term deployments such as <em>community networks</em> usually choose <em>public</em> mode, whereas quick, temporal or ephemeral deployments usually choose <em>natted</em> mode.") .. "<br/> <br/>" ..
translate("Choose an operating mode for this node:") .. "<br/> <br/>" ..
translate("· <i><strong>public</strong></i> mode, for making local devices connected to this node accessible from anywhere in the mesh network") .. "<br/>" ..
translate("· <i><strong>natted</strong></i> mode, for keeping local devices connected to this node hidden from the rest of the mesh by a NAT") .. "<br/> <br/>"
translate("Static, long-term deployments such as <i>community networks</i> usually choose <i>public</i> mode, whereas quick, temporal or ephemeral deployments usually choose <i>natted</i> mode.")
translate("· <em>public</em> mode, for making local devices connected to this node accessible from anywhere in the mesh network") .. "<br/>" ..
translate("· <em>natted</em> mode, for keeping local devices connected to this node hidden from the rest of the mesh by a NAT") .. "<br/> <br/>"
nodemode = m:field(ListValue, "_nodemode", translate(" "), translate("Select <i>public</i> or <i>natted</i> mode."))
nodemode = m:field(ListValue, "_nodemode", translate(" "), translate("Select <em>public</em> or <em>natted</em> mode."))
nodemode:value("community","public")
nodemode:value("roaming","natted")
......@@ -128,9 +138,8 @@ local roaming_ipaddress_help
roaming_ipaddress_help = m:field(DummyValue,"roaming_ipaddress_help")
roaming_ipaddress_help.rawhtml = true
roaming_ipaddress_help:depends("_nodemode","roaming")
roaming_ipaddress_help.default = "<strong>" .. translate("Mesh-wide public IPv4 address and network mask") .. "</strong>" .. "<br/> <br/>" ..
translate("In <i>natted</i> mode, all qMp devices in the mesh network need a unique IPv4 address with a /32 netmask.") .. " " ..
translate("If unsure about which one to select, leave the field blank and a random one will be assigned automatically.").."<br/> <br/>"
roaming_ipaddress_help.default = translate("In <em>natted</em> mode, all qMp devices in the mesh network need a unique IPv4 address with a /32 netmask.") .. " " ..
translate("If unsure about which one to select, leave the field blank and a random one will be assigned automatically.").."<br/> <br/>"
local nodeip_roaming = m:field(Value, "_nodeip_roaming", " ", translate("Write the mesh-wide public IPv4 address for this device with a /32 netmask, or leave it blank to get a random one."))
nodeip_roaming:depends("_nodemode","roaming")
......@@ -148,26 +157,23 @@ nodeip_roaming.default=rip
-- Mesh IPv4 address (public)
local community_addressing_help
community_addressing_help = m:field(DummyValue,"community_addressing_help")
community_addressing_help.rawhtml = true
community_addressing_help:depends("_nodemode","community")
community_addressing_help.default = "<strong>" .. translate("Mesh-wide public IPv4 address and network mask") .. "</strong>" .. "<br/> <br/>" ..
translate("In <i>public</i> mode, all qMp devices in the mesh network need a unique IPv4 address and a subnetwork mask.") .. " " ..
community_addressing_help.default = "<strong>" .. " " .. "</strong>" .. "<br/> <br/>" ..
translate("In <em>public</em> mode, all qMp devices in the mesh network need a unique IPv4 address and a subnetwork mask.") .. " " ..
translate("Specify the IP address and the subnetwork mask for this device, according to the planning of your community network or deployment.") .. " " ..
translate("End-user devices will get an IPv4 address within the valid range determined by these two values.").."<br/> <br/>"
local nodeip = m:field(Value, "_nodeip", " ",
translate("Main IPv4 address for this device."))
local nodeip = m:field(Value, "_nodeip", " ", translate("Main IPv4 address for this device."))
nodeip:depends("_nodemode","community")
nodeip.default = "10.30."..util.trim(util.exec("echo $((($(date +%M)*$(date +%S)%254)+1))"))..".1"
nodeip.optional=false
nodeip.datatype="ip4addr"
local nodemask = m:field(Value, "_nodemask"," ",
translate("Network mask to be used with the IPv4 address above."))
-- Mesh IPv4 netmask (public)
local nodemask = m:field(Value, "_nodemask"," ", translate("Network mask to be used with the IPv4 address above."))
nodemask:depends("_nodemode","community")
nodemask.default = "255.255.255.224"
nodemask:value("255.255.255.0", "255.255.255.0 (/24, 254 hosts)")
......@@ -176,7 +182,6 @@ nodemask:value("255.255.255.192", "255.255.255.192 (/26, 62 hosts)")
nodemask:value("255.255.255.224", "255.255.255.224 (/27, 30 hosts)")
nodemask:value("255.255.255.240", "255.255.255.240 (/28, 14 hosts)")
nodemask:value("255.255.255.248", "255.255.255.248 (/29, 6 hosts)")
nodemask.datatype="ip4addr"
if networkmode == "community" then
......@@ -185,16 +190,20 @@ if networkmode == "community" then
end
------------------------
-- Network interfaces --
------------------------
-- Wired interfaces
local wired_interface_mode_help
wired_interface_mode_help = m:field(DummyValue,"wired_interface_mode_help")
wired_interface_mode_help.rawhtml = true
wired_interface_mode_help.default = "<strong>" .. translate("Wired interfaces") .. "</strong>" .. "<br/> <br/>" ..
wired_interface_mode_help.default = "<h3>" .. translate("Network interfaces") .. "</h3>" .. "<br/> <br/>" ..
translate("Select the working mode of the wired network interfaces") .. ":<br/> <br/>" ..
translate("· <strong>LAN</strong> mode is used to provide connectivity to end-users (a DHCP server will be enabled to assign IP addresses to the devices connecting)") .. "<br/>" ..
translate(" · <strong>WAN</strong> mode is used on interfaces connected to an Internet up-link or any other gateway connection") .. "<br/>" ..
translate(" · <strong>None</strong>, to not use the interface neither as LAN nor as WAN") .. "<br/> <br/>" ..
translate(" · <strong>Mesh via wired interface</strong> is used to expand the mesh network when connecting the wired interface to other qMp devices") .. "<br/> <br/>"
translate("· <em>LAN</em> mode is used to provide connectivity to end-users (a DHCP server will be enabled to assign IP addresses to the devices connecting)") .. "<br/>" ..
translate(" · <em>WAN</em> mode is used on interfaces connected to an Internet up-link or any other gateway connection") .. "<br/>" ..
translate(" · <em>None</em>, to not use the interface neither as LAN nor as WAN") .. "<br/> <br/>" ..
translate(" · <em>Mesh via wired interface</em> is used to expand the mesh network when connecting the wired interface to other qMp devices") .. "<br/> <br/>"
-- Get list of devices {{ethernet}{wireless}}
devices = qmpinfo.get_devices()
......@@ -241,17 +250,20 @@ for i,v in ipairs(devices.eth) do
nodedevs_ethmesh[i] = {v,emeshmode}
end
--[[ MeshAll option for wired devices is deprecated
meshall = m:field(Flag, "_meshall", translate("Use mesh in all wired devices"),translate("If this option is enabled, all the wired network devices will be used for meshing"))
meshall.default = "0"
]]--
-- Wireless interfaces
local wireless_interface_mode_help
wireless_interface_mode_help = m:field(DummyValue,"wireless_interface_mode_help")
wireless_interface_mode_help.rawhtml = true
wireless_interface_mode_help.default = "<strong>"..translate("Wireless interfaces").."</strong>".."<br/> <br/>"..translate("Select the working mode of the wireless network interfaces")..":<br/> <br/> · "..translate("<strong>Ad hoc (mesh)</strong> mode is used to link with other mesh nodes operating in ad hoc mode") .."<br/> · "..translate("<strong>802.11s (mesh)</strong> mode is used to link with other mesh nodes operating in ad hoc mode") .."<br/> · "..translate("<strong>AP (mesh)</strong> mode is used to create an access point for other mesh nodes to connect as clients") .."<br/> · "..translate("<strong>Client (mesh)</strong> mode is used to link with a mesh node operating in AP mode") .."<br/> · "..translate("<strong>AP (LAN)</strong> mode is used to generate an access point for end users' devices") .."<br/> · "..translate("<strong>Client (WAN)</strong> mode is used to link work as a client of an access point providing an up-link Internet access") .."<br/> · "..translate("<strong>Ad hoc (mesh) + AP (LAN)</strong> combines both modes on a single interface") .."<br/> · "..translate("<strong>802.11s (mesh) + AP (LAN)</strong> combines both modes on a single interface").."<br/> <br/>"
wireless_interface_mode_help.default = translate("Select the working mode of the wireless network interfaces:") .. "<br/> <br/>" ..
translate("· <em>Ad hoc (mesh)</em> mode is used to link with other mesh nodes operating in ad hoc mode") .. "<br/>" ..
translate("· <em>802.11s (mesh)</em> mode is used to link with other mesh nodes operating in ad hoc mode") .."<br/>" ..
translate("· <em>AP (mesh)</em> mode is used to create an access point for other mesh nodes to connect as clients") .. "<br/>" ..
translate("· <em>Client (mesh)</em> mode is used to link with a mesh node operating in AP mode") .. "<br/>" ..
translate("· <em>AP (LAN)</em> mode is used to generate an access point for end users' devices") .. "<br/>" ..
translate("· <em>Client (WAN)</em> mode is used to link work as a client of an access point providing an up-link Internet access") .. "<br/>"..
translate("· <em>Ad hoc (mesh) + AP (LAN)</em> combines both modes on a single interface") .. "<br/>" ..
translate("· <em>802.11s (mesh) + AP (LAN)</strong> combines both modes on a single interface").."<br/> <br/>"
nodedevs_wifi = {}
......
--[[
qMp - Quick Mesh Project - https://www.qmp.cat
Copyright © 2011-2017 Fundació Privada per a la Xarxa Oberta, Lliure i Neutral, guifi.net
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
--]]
local sys = require("luci.sys")
local http = require "luci.http"
local util = require "luci.util"
local uciout = uci.cursor()
m = Map("qmp", "qMp basic network settings", translate("This page allows to configure the basic network settings qMp device, like the node mode or the mesh-wide public IPv4 address.") .. "<br/> <br/>" .. translate("You can check the on-line documentation at <a href=\"https://www.qmp.cat/Web_interface\">https://www.qmp.cat/Web_interface</a> for more information about the different options."))
-- Network mode change was requested, rebuild interface config and reload page
if m:formvalue("cbid.configuration.network.basic._switch") then
-- Get new protocol
local ptype = m:formvalue("cbid.configuration.network.basic.ignore" % net:name()) or "-"
-- reload page
luci.http.redirect(luci.dispatcher.build_url("qmp/configuration/network/advanced", arg[1]))
return
end
---------------
-- Node mode --
---------------
node_mode = m:section(NamedSection, "roaming", "qmp", translate("Node mode"),
translate("The <em>node mode</em> option defines whether qMp makes the devices connected to the LAN interfaces of the node visible to the rest of the mesh network or hidden behind a NAT.") .. " " ..
translate("Static, long-term deployments such as <em>community networks</em> usually choose <em>public</em> mode, whereas quick, temporal or ephemeral deployments usually choose <em>natted</em> mode.") .. "<br/> <br/>" ..
translate("Choose an operating mode for this node:") .. "<br/> <br/>" ..
translate("· <em>public</em> mode, for making local devices connected to this node accessible from anywhere in the mesh network") .. "<br/>" ..
translate("· <em>natted</em> mode, for keeping local devices connected to this node hidden from the rest of the mesh by a NAT") .. "<br/> <br/>")
node_mode.addremove = false
roaming = node_mode:option(ListValue, "ignore", " ", translate("Select <em>public</em> or <em>natted</em> mode."))
nm_switch = node_mode:option(Button, "_switch")
nm_switch.title = translate("Really switch mode?")
nm_switch.inputtitle = translate("Switch mode")
nm_switch.inputstyle = "apply"
rv = {}
rv["0"] = translate("natted")
rv["1"] = translate("public")
local i, nm
for i, nm in pairs(rv) do
roaming:value(i, i.."-"..nm)
if i ~= uciout:get("qmp","roaming","ignore") then
nm_switch:depends("ignore", i)
end
end
-------------------------------------
-- Natted mode public IPv4 address --
-------------------------------------
if uciout:get("qmp","roaming","ignore") == "0" then
public_address = m:section(NamedSection, "networks", "qmp", translate("Mesh-wide public IPv4 address and network mask (natted)"), translate("TODO"))
public_address.addremove = false
-- Option bmx6_ipv4_address
nodeip = public_address:option(Value, "bmx6_ipv4_address", "Main IPv4 address", translate("TODO."))
elseif uciout:get("qmp","roaming","ignore") == "1" then
public_address = m:section(NamedSection, "networks", "qmp", translate("Mesh-wide public IPv4 address and network mask (public)"), translate("TODO"))
public_address.addremove = false
-- Option bmx6_ipv4_address
lanaddress = public_address:option(Value, "lan_address", "Main IPv4 address", translate("TODO."))
lanaddress.default = "10.30."..util.trim(util.exec("echo $((($(date +%M)*$(date +%S)%254)+1))"))..".1"
end
--------------------------
-- Commit
-------------------------
function m.on_commit(self,map)
-- http.redirect("/luci-static/resources/qmp/wait_long.html")
--luci.sys.call('/etc/qmp/qmp_control.sh configure_all > /tmp/qmp_control_network.log &')
end
return m
......@@ -84,7 +84,7 @@
</head>
<body onload="onLoad();">
<div id="progress_screen">
<img src="logo.png" class="align-center" />
<img src="logo.png" class="align-center" alt="qMp logo"/>
<p>The configuration is being applied, please wait a moment...</p>
<div id="progress_wrapper"><div id="progress"></div></div>
</div>
......
......@@ -84,7 +84,7 @@
</head>
<body onload="onLoad();">
<div id="progress_screen">
<img src="logo.png" class="align-center" />
<img src="logo.png" class="align-center" alt="qMp logo"/>
<p>The configuration is being applied, please wait a moment...</p>
<div id="progress_wrapper"><div id="progress"></div></div>
</div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment